Animation issues when going from last to first item.
See original GitHub issueWhen I try to animate the slide transition with some opacity, everything works fine except when I go forward from last to first element. Even when I go backward from first to last it works fine.
The gif is a bit more glitchy than the actual result but we can clearly see that when going from slide “4” to “1” the animation skips. But not when going from slide “1” to “4”.
[ https://jsfiddle.net/b5bqk68j/6741/ ]
====================================================================
Steps to reproduce the problem
-
Initialize a slick slider with the following config
let sliderConfig = { centerMode: true, centerPadding: '400px', infinite: true, slidesToShow: 1, prevArrow: $prevArrow, nextArrow: $nextArrow };
-
Add transition to slide or element in the slide. in my case:
.slick-animate { opacity: 0.5; transition: opacity 0.48s ease-in-out; } .slick-center { .slick-animate { opacity: 1; } }
-
Use any means of going forward through the slides and see the effect.
====================================================================
What is the expected behaviour?
Every slides animates properly (like when going backwards).
====================================================================
What is observed behaviour?
When going from last to first the animation is glitching. (probably because of the slide cloning/switching)
====================================================================
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
Don’t know why this is closed since the issue is still here in the latest version. I fixed it in my project by applying a custom class “.slick-target” to the slide that slick is transitioning to (so next or prev slide depending on direction) and then applying CSS to both “.slick-target” and “.slick-current” simultaneously. No delay, just smooth transitions all around.
So JS:
And CSS:
The detection in my JS code of whether we’re moving left or right only works for 3+ slides I think, because that was all I needed, but you could change that line to be much much longer if you need to detect this. See #1679.
This should be reopened so it’s fixed in the library itself. maybe @explorador can send a PR for this?