akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.76k stars 2.11k forks source link

Flicker on animation #248

Open AHB opened 8 years ago

AHB commented 8 years ago

http://webrafter.com/opensource/react-slick

The Multiple Items slider end slide flickers when animating the rollover from the 3rd item, back to the first.

bug

Will also flicker when going from the 1st item, back to the 3rd. Seems to happen on all sliders with infinite enabled and slidesToScroll > 1.

akiran commented 8 years ago

On which browser and os you are seeing this issue ?

I don't see this issue in mac and chrome

AHB commented 8 years ago

I'm also on Mac, Chrome 48.

mpaulucci commented 8 years ago

I have the same problem. I dont see the flickering in Mac but I see it on my Android Phone. If you look carefully you will see a delay in the updating of the active dot, that can be reproduced in Mac as well.

I think the issue may be related to setting a wrong value of currentSlide.

I have a working example with 3 Slides, infinite turned on. If I log currentSlide in the render method of Dots, when sliding from slide 2 (the last one) to slide 3 (should go to slide 0), I get this:

Example with 3 slides, sliding one time:

2016-03-02 12:38:41.360 dots.js:34 [Dots] Current slide: 2
2016-03-02 12:38:41.466 dots.js:34 [Dots] Current slide: 3 // Bug!
2016-03-02 12:38:41.987 dots.js:34 [Dots] Current slide: 0

currentSlide is incorrectly set to 3 temporary (half a second) before being correctly set to 0.

The setState with the error is this one: https://github.com/akiran/react-slick/blob/9bbe0fa9191bb5b1156cec4755532ee108f14cbc/src/mixins/helpers.js#L223 (sets currentSlide to 3)

And this one corrects it: https://github.com/akiran/react-slick/blob/9bbe0fa9191bb5b1156cec4755532ee108f14cbc/src/mixins/helpers.js#L214 (sets currentSlide to 0)

The difference between the two setState is that the first one sets it to targetSlide and the second one to currentSlide. Changing the first one to currentlSlide fixes the issue, but I'm not sure about the implications of this change.

[Update]: I've tested the change on mobile, it fixes the dots delay issue, but not the flicker

akiran commented 8 years ago

@AHB @mpaulucci Release 0.11.1 with this fix. Can you check

mpaulucci commented 8 years ago

Hi @akiran, sorry about my ambiguous message. I thought the flicker was related to the dots issue and solving one would solve both, but it seems they are not related after all, so the flickr issue is still present

demobo-com commented 8 years ago

I also see the flickering issue at the last item. I am using react-slick 0.11.1, Mac and Chrome 48.

apennell commented 8 years ago

I'm having the same issue in Chrome on a Mac and I'm glad it's already been detected and worked on! There's no problem in Safari or Firefox. I have infinite set to true and when the slides finish and go back to the first set, there is a flicker on the first slide on the far left. I hope this can be resolved soon! Thank you for this component though, it was just what I needed.

Leannechn commented 6 years ago

Is this issue fixed now? I'm having the same issue in Chrome on a Mac。 Can you tell me how to solve it? I want to know where the bug is。It`s so kind of you.

NikitaMazur commented 6 years ago

The same bug still here :(

laveesingh commented 6 years ago

@Leannechn @NikitaMazur I'll make sure to look into this.

davydepauw commented 6 years ago

I just detected the same flicker in our implementation...

laveesingh commented 6 years ago

@davydepauw I tried several configs but I was unable to reproduce any such flick, could you help me by giving some sort of demo-link or code snippet?

Leannechn commented 6 years ago

@laveesingh This phenomenon is random, when the slide speed is relatively fast when there is a greater probability.In particular, from last slide back to the first one. The reason for the preliminary investigation may be a chrome`s bug. I guess this is the reason,you can google to search: chrome trandition flicker / chrome trandition blink . https://stackoverflow.com/questions/2946748/iphone-webkit-css-animations-cause-flicker

leomyth330 commented 6 years ago

Same bug here when sliding between last & first items.

leomyth330 commented 6 years ago

Fast reproducing steps from sample code in mac chrome.

  1. Reduce items size to 3 from 6(original) in single item mode.
  2. Scroll between first item(1) and last item(3) rapidly.
dlong500 commented 6 years ago

I'm seeing this flicker with Chrome on Windows even in single item mode when transitioning from the last slide to the first. Unfortunately it is very noticeable.

xpander001 commented 6 years ago

Same here, single mode from the last item to the first. Any possible solution?

laveesingh commented 6 years ago

We would highly appreciate PRs regarding this.

ghost commented 6 years ago

@laveesingh currently getting the flicker at the end of the loop with this setting:

const settings = {
    autoplay: true,
    dots: false,
    speed: 700,
    infinite: true,
    slidesToShow: 1,
    slidesToScroll: 1,
    arrows: false,
    draggable: true,
};
<Slider {...settings}>
    <h1 className={s.sliderImage}>test</h1>
    <h1 className={s.sliderImage}>test</h1>
    <h1 className={s.sliderImage}>test</h1>
</Slider>
.sliderImage {
    height: 500px;
    width: 100%;
    background: linear-gradient(-45deg, tomato, pink);
}
nanyang24 commented 6 years ago

This problem is still recurrence

chrome: 65.0.3325.181(64) macOS 10.13.3

This is the 2018…………

patrikmolnar commented 6 years ago

Having the same issue still.. on Mac, using Chrome..

i5on9i commented 6 years ago

I also have a same issue on Windows, using Chrome.

FYI, I've tested with the css backface-visibility: hidden; and the option like the below

I used 3 slides.

infinite: true,
speed: 3000,
autoplay: true,
autoplaySpeed: 3000, // 3s
slidesToShow: 1,
slidesToScroll: 1,

After some test, I think it's because the react-slick uses the css transform.

Because with backface-visibility: hidden; , I see the flicking of the whole part of the first slide. without it, I see only a part of the first slide.

Also, the flicking part of the first slide is different depending on the speed option of the react-slide.

Final clue is when I uses the speed 3000ms, which is much slower than previous test, sliding animation works differently. When the slide is changed from 1st to 2nd after one loop, slide goes back to the 2nd slide in opposite direction.( with the below diagram, 1-->2-->3-->1+ --> 2) In this case, I can't see the flicking.

+------+    +------+   +------+  +-------+  +-------+
|   1  |    |   2  |   |   3  |  |   1+  |  |   2+  |
+------+    +------+   +------+  +-------+  +-------+
AdamColton8 commented 6 years ago

it helped me

.slick-slide,
.slick-slider .slick-track,
.slick-slider .slick-list
{
  -webkit-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  -ms-transform: translate3d(0, 0, 0);
  -o-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);

  -webkit-transform: translateZ(0);
  -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  -o-transform: translateZ(0);
  transform: translateZ(0);

  -webkit-perspective: 1000;
  -moz-perspective: 1000;
  -ms-perspective: 1000;
  perspective: 1000;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
}
Leannechn commented 6 years ago

To delay one frame time after 'speed' ,16ms or more. It can hack this flicker too. And it does not have any perception of the user. image inner-slider.js 405: speed + 16

maddhruv commented 6 years ago

Any update on this @akiran

akiran commented 6 years ago

@maddhruv Yes, Sometimes flicker happens. We couldn't reproduce this issue reliably

We should get back to this issue after fixing other issues

maddhruv commented 6 years ago

We should get back to this issue after fixing other issues

Okay

vii120 commented 6 years ago

It works for me by adding useTransform: false to settings. Found it from slick issue #1890

pixelomo commented 5 years ago

@vii120 thanks!!

antoniojps commented 5 years ago

I'm still having this issueuseTransform: false didnt make it for me.

Update: Upgraded the package, all fine now with useTransform set to false 🎉

jkincheloe33 commented 5 years ago

Why would this get moved to low priority? Issue has been present for years now.

Console-buche commented 2 years ago

It works for me by adding useTransform: false to settings. Found it from slick issue #1890

Just in case this might help someone : setting useTransform: false fixed the issue for me using antd carousel component. Had jerky/flickering issues and some delay on dots updating on iOS. All gone and smooth.

Lloydinator commented 2 years ago

Yep after hours of painstaking research, useTransform: false works for me.

iamlykke commented 1 year ago

I use this slider for showing event-posters on the TV and flickering was very noticeable (slide was 50% cut for 5-6 seconds). useTransform: false solved this issue.

hitchcliff commented 1 year ago

issue still occurs

IlyaApaniuk commented 1 year ago

The issue is still present, 2023 (facepalm)

eminsonlu commented 1 year ago

issue still occurs june 2023

web-thidinh commented 1 year ago

Update on October 28, 2023. Chrome, Firefox, Coc Coc is ok. Only flicker on Edge. Solved by add useTransform: false. But in condition you don't have custom arrow button, in my case. A bit confusing

FadyBoj commented 9 months ago

I use this slider for showing event-posters on the TV and flickering was very noticeable (slide was 50% cut for 5-6 seconds). useTransform: false solved this issue.

This worked for me just fine