React-slick: slickGoTo(0) is not working

Created on 28 Aug 2016  路  8Comments  路  Source: akiran/react-slick

any other index above 0 does.

Most helpful comment

the slider is on the 2nd slide.
I have 4 elements.
index is 0 to 3.

every slickGoto is working except 0, 0 supposed to get the slider to the beginning.

All 8 comments

If the slider is already at 1st slide, slickGoTo(0) will not have any effect

the slider is on the 2nd slide.
I have 4 elements.
index is 0 to 3.

every slickGoto is working except 0, 0 supposed to get the slider to the beginning.

ok, I will check

Just looking at the code, I think it might be here:

https://github.com/akiran/react-slick/blob/master/src/inner-slider.jsx#L104

  slickGoTo: function (slide) {
    slide && this.changeSlide({
      message: 'index',
      index: slide,
      currentSlide: this.state.currentSlide
    });
  },

If you go to slide 0, then this will evaluate to false since 0 is falsey in js. Maybe changing that first line to something like:

(slide || slide === 0) && this.changeSlide({

This issue is fixed in 0.13.4 version

Does slickGoTo remove the animation ? How to keep it ..

@manodupont You won't see animation If there is a state change just before calling slickGoTo becuase it causes re-render of react-slick.

You should avoid re-render of react-slick to see animation.

same issue
version 0.23.1
goes to each slide without problems except 0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

walker-jiang picture walker-jiang  路  3Comments

ramyatrouny picture ramyatrouny  路  3Comments

will88 picture will88  路  3Comments

quarklemotion picture quarklemotion  路  4Comments

nicreichert picture nicreichert  路  3Comments