Skip to content

slickNext() and slickPrev() not behaving correctly when initialSlide is > 0 and infinite is false #2140

Closed
@david98

Description

@david98

Basically, as the title says, if you create a slider with the following options:

var settings = {
  infinite: false,
  initialSlide: 2  // any value that is not 0 will still cause this problem
};

The slider correctly displays the slide at index 2, but the first call to slickNext() (either through the arrows or via code) will show slide 1 and the first call to slickPrev() will show slide 0. It looks like internally the slider object still thinks it's displaying index 0 even though initialSlide is set to a different value. This is supported by the fact that calling slickGoTo(2) once after page render completely solves the issue (that is, subsequent calls to slickNext() and slickPrev() behave as they should).

CodeSandbox: https://codesandbox.io/s/initial-slide-issue-qjhzxd?file=/index.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions