在Slick Vertical Carousel中,当第一个元素在视图中时,轮播的布局会发生变化

Roh*_*mar 11 carousel slick.js

我用Slick创建了一个垂直旋转木马.我在设计上做了一些改变,除了当第一个元素在旋转木马的视图中时,一切都按照我想要的方式工作.在我的轮播中有4个项目可见但是当第一个元素位于四个项目中的第一个时,则在轮播的布局中发生了错误.
我的网址是 -
http://www.w3karigar.com/mobile/game2/
您可以在我的网站上看到该代码.但我在下面列了几个 -

    $('#games-carousel').slick({
        dots: false,
        arrows: false,
        infinite: true,
        speed: 200,
        slidesToShow: 4,
        vertical: true,
        verticalSwiping: true,
        swipeToSlide: true
    });
    $('#games-carousel').slick('setPosition');
Run Code Online (Sandbox Code Playgroud)
#games-carousel .item {
    display: block;
    width: 100%;
    height: 70px;
    opacity: 0.2;
    padding: 1px 0;
    transition: all 0.2s ease-in;
    transform: translate3d(0,0,0);
}
#games-carousel .item .cover, #games-carousel .item .info {
    width: 50%;
    float: left;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}
#games-carousel .item .cover {
    padding: 0 7px 0px 5px;
    overflow: visible;
}
#games-carousel .item .cover img {
    max-height: 100%;
    width: auto;
    float: right;
    box-shadow: 2px 2px 2px rgba(0,0,0,0.1);
}
#games-carousel .item .info {
    padding-left: 7px;
    font-size: 11px;
    color: #C5ED34;
    text-transform: uppercase;
}
#games-carousel .item .info span {
    font-size: 14px;
    display: block;
    line-height: 16px;
    color: #ffffff;
}

#games-carousel .item.slick-current + .slick-active {
    height: 150px;
    opacity: 1;
    padding: 5px 0;
}
#games-carousel .item.slick-current + .slick-active .info {
    font-size: 17px;
}
#games-carousel .item.slick-current + .slick-active .info span {
    font-size: 25px;
    line-height: 30px;
}
#games-carousel .item.slick-current + .slick-active .cover img {
    box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.2);
}

#games-carousel .item.slick-active.slick-current, #games-carousel .item.slick-current + .slick-active + .slick-active {
    height: 100px;
    opacity: 0.4;
}
#games-carousel .item.slick-current + .slick-active + .slick-active .info, #games-carousel .item.slick-current .info {
    font-size: 14px;
}
#games-carousel .item.slick-current + .slick-active + .slick-active .info span, #games-carousel .item.slick-current .info span {
    font-size: 18px;
    line-height: 22px;
}
#games-carousel .item.slick-current + .slick-active + .slick-active .cover img, #games-carousel .item.slick-current .cover img {
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
}
#games-carousel .item {
    display: block;
    width: 100%;
    height: 70px;
    opacity: 0.2;
    padding: 1px 0;
    transition: all 0.2s ease-in;
    transform: translate3d(0,0,0);
}
#games-carousel .item .cover, #games-carousel .item .info {
    width: 50%;
    float: left;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}
#games-carousel .item .cover {
    padding: 0 7px 0px 5px;
    overflow: visible;
}
#games-carousel .item .cover img {
    max-height: 100%;
    width: auto;
    float: right;
    box-shadow: 2px 2px 2px rgba(0,0,0,0.1);
}
#games-carousel .item .info {
    padding-left: 7px;
    font-size: 11px;
    color: #C5ED34;
    text-transform: uppercase;
}
#games-carousel .item .info span {
    font-size: 14px;
    display: block;
    line-height: 16px;
    color: #ffffff;
}

#games-carousel .item.slick-current + .slick-active {
    height: 150px;
    opacity: 1;
    padding: 5px 0;
}
#games-carousel .item.slick-current + .slick-active .info {
    font-size: 17px;
}
#games-carousel .item.slick-current + .slick-active .info span {
    font-size: 25px;
    line-height: 30px;
}
#games-carousel .item.slick-current + .slick-active .cover img {
    box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.2);
}

#games-carousel .item.slick-active.slick-current, #games-carousel .item.slick-current + .slick-active + .slick-active {
    height: 100px;
    opacity: 0.4;
}
#games-carousel .item.slick-current + .slick-active + .slick-active .info, #games-carousel .item.slick-current .info {
    font-size: 14px;
}
#games-carousel .item.slick-current + .slick-active + .slick-active .info span, #games-carousel .item.slick-current .info span {
    font-size: 18px;
    line-height: 22px;
}
#games-carousel .item.slick-current + .slick-active + .slick-active .cover img, #games-carousel .item.slick-current .cover img {
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
}
Run Code Online (Sandbox Code Playgroud)
<div id="games-carousel">
    <div class="item adventure">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
    <div class="item adventure">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
    <div class="item adventure">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
    <div class="item adventure">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
    <div class="item lorem">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
    <div class="item lorem">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
    <div class="item lorem">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
    <div class="item lorem">
        <div class="cover">
            <img class="cover-img" src="images/ac3.jpg" alt="" />
        </div>
        <div class="info">
            <span>Assassin's Creed 3</span>Adventure
        </div>
    </div>
  </div>
Run Code Online (Sandbox Code Playgroud)

Ste*_*ain 3

我的解决方案重点关注您无限滚动的事实。我认为 Slide.js 错误地将最后一张幻灯片 [第一张之前的幻灯片] 的高度计算为 70 像素,而它应该是 100 像素,导致第一张幻灯片向上移动 30 像素。

看起来您正在使用以下 css 调整上一张和下一张幻灯片的高度:

#games-carousel .item.slick-active.slick-current, 
#games-carousel .item.slick-current + .slick-active + .slick-active {
    height: 100px;
    opacity: 0.4;
}
Run Code Online (Sandbox Code Playgroud)

看起来您还需要调整 .slick-active 与 .slick-current 以确保您选择了正确的一个。

选项:

1. 消除周围两个块的高度增加可以使流程完美运行。效果有所不同,但并不跳跃。

#games-carousel .item.slick-active.slick-current, 
#games-carousel .item.slick-current + .slick-active + .slick-active {
    opacity: 0.4;
}
Run Code Online (Sandbox Code Playgroud)

删除高度的 Slide.js

2. 移除之前块中的高度增加使流程完美运行。效果有所不同,但并不跳跃。

#games-carousel .item.slick-active.slick-current{
    opacity: 0.4;
}
#games-carousel .item.slick-current + .slick-active + .slick-active {
    height: 100px;
    opacity: 0.4;
}
Run Code Online (Sandbox Code Playgroud)

Slide.js 与 next