slick icon indicating copy to clipboard operation
slick copied to clipboard

Going from first to last slide, or from last to first slide, on infinite mode doesn't animate

Open miguelleite opened this issue 12 years ago • 13 comments

Hey there. In my solution, I wanted the next/previous slides to have a scale of 75%, and the centered one with 100% scale.

I'm using the following settings:

$('#slick-carousel').slick({
        autoplay: true,
        arrows: false,
        centerMode: true,
        dots: true,
        slidesToShow: 1,
        centerPadding: '295px',
        infinite: true
});

In my CSS I have the following:

#slick-carousel .slick-slide.slick-active.slick-center {
        -webkit-transform: scale(1);
        -ms-transform: scale(1);
        -o-transform: scale(1);
        transform: scale(1);
}
#slick-carousel .slick-slide {
        -webkit-transform: scale(0.75);
        -ms-transform: scale(0.75);
        -o-transform: scale(0.75);
        transform: scale(0.75);
        -webkit-transition: all .3s linear;
        -o-transition: all .3s linear;
        transition: all .3s linear;
}

It works great, unless when I slide from last to first slide, or from the first to last slide. Any thoughts on that? I'd appreciate any help.

Thanks in advance.

miguelleite avatar Aug 21 '14 11:08 miguelleite

It is because of the cloned slide. I'm in the middle of a launch, I'll take a look when I get some bandwidth.

kenwheeler avatar Aug 21 '14 16:08 kenwheeler

Thanks @kenwheeler. Will wait for it :)

miguelleite avatar Aug 21 '14 17:08 miguelleite

Is this fixed? I have the same problem, but i can't reproduce on jsfiddle. demo on the demo site also works fine. (i'm using 1.3.15)

Edit: JSFiddle: http://jsfiddle.net/ettmrgcj/

ponyfleisch avatar Dec 09 '14 07:12 ponyfleisch

Not a fix, but a workaround... targeting .slick-center for the transition/animation works if you have centerMode:true enabled:

http://jsfiddle.net/1wyegw6L/

The issue is that when it "wraps" around, it is showing the cloned item first, and then changing the translate value to show the original, without ever applying the slick-active class to the cloned item. slick-center does get applied to both though.

EDIT: ...aaaaaand now I see that this workaround had already been posted: https://github.com/kenwheeler/slick/issues/1720#issuecomment-141523915

nickmelville avatar Nov 04 '15 21:11 nickmelville

This doesn't seem to be fixed in 1.6.0 yet.

As @nickmelville described, when transitioning from the first or last slide to the cloned one on an infinite Slick slider, the slick-active class isn't applied to the clone.

It feels wrong having to resort to centerMode: true to work around the problem.

bbodien avatar Jan 04 '17 17:01 bbodien

+1. Any update on this?

omzy avatar Jul 17 '17 01:07 omzy

No luck from my side either :(

eugeneAamplify avatar Oct 25 '17 03:10 eugeneAamplify

+1 running into this issue as well. Attempting to use centerMode: true, but even when targeting the .slick-center class, transition pops remain.

aaronransley avatar Nov 18 '17 07:11 aaronransley

First, thanks @kenwheeler for this awesome piece of work!

For those of you who are still facing this issue in the 1.8.0 version, I was able to get rid of it by downgrading to 1.6.0.

chrisandrewcl avatar Dec 01 '17 12:12 chrisandrewcl

@chrisandrewcl Thanks a lot

prozhkov avatar Mar 23 '18 12:03 prozhkov

Still having the issue with centerMode. Any solution that doesn't require downgrading?

rbrlortie avatar Mar 21 '19 15:03 rbrlortie

Downgrading to 1.6.0 still doesn't fix it.

tfadz avatar May 14 '19 16:05 tfadz

I'm still facing this issue even after downgrading to 1.6, setting centerMode and targeting centered slide with .slick-center

y1n0 avatar Oct 09 '20 14:10 y1n0