Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing slide not in focus causes slider.currentslide to increment #1449

Open
benjiew opened this issue Oct 29, 2015 · 1 comment
Open

Removing slide not in focus causes slider.currentslide to increment #1449

benjiew opened this issue Oct 29, 2015 · 1 comment
Assignees
Projects
Milestone

Comments

@benjiew
Copy link

benjiew commented Oct 29, 2015

I've got a slider with two slides - slide 1 contains a video. I've hooked up some code to remove slide 1 when the video finishes playing, however this could be when you are viewing slide 2. The result of this is nothing showing.

N.B. If the slide in view is slide 1, then slide 2 is shown as expected.

I call slider.removeslide(0) but the slider.currentSlide value increments to 2 (even this should only hit a max of 1 (zero indexed) with 2 slides, let alone 1.

I've tracked this down to this portion of the code in the slider.update method:

// update currentSlide and slider.animatingTo if necessary
if (!carousel) {
if (pos < slider.currentSlide) {
slider.currentSlide += 1;
} else if (pos <= slider.currentSlide && pos !== 0) {
slider.currentSlide -= 1;
}
slider.animatingTo = slider.currentSlide;
}

So if pos is 0, and currentSlide is 1, currentSlide is incremented to 2?

@jeffikus jeffikus self-assigned this Oct 30, 2015
@benjiew
Copy link
Author

benjiew commented Nov 4, 2015

I've managed to resolve this by replacing the above code with the following:
if (!carousel) {
if (pos <= slider.currentSlide && slider.currentSlide !== 0) {
slider.currentSlide -= 1;
}
slider.animatingTo = slider.currentSlide;
}

@jeffikus jeffikus added this to the 2.6.5 milestone Sep 15, 2017
@jeffikus jeffikus added this to Assess in 2.6.5 Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
2.6.5
Assess
Development

No branches or pull requests

2 participants