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

Multiple sliders on the same page #14

Closed
sergiofornet opened this issue Aug 14, 2020 · 5 comments
Closed

Multiple sliders on the same page #14

sergiofornet opened this issue Aug 14, 2020 · 5 comments

Comments

@sergiofornet
Copy link
Contributor

When trying to use two (or more) sliders at the same time, the last one works properly but any other one transitions back and forth to active slide when arrows are clicked. I don't know why but smoothTransition is called twice so it transitions, then the slides are updated and then it transitions again.

Any clue on why is this happening?

@sergiofornet
Copy link
Contributor Author

It seems the transitionend event is triggered twice for every slider on a page but the last. Using a ref to the slider and adding the listener to it instead of window did the trick for me.

@AvinashKomaturi
Copy link

Hey @sergiofornet, I am also facing the same issue. can you please explain to which component should I create ref?

@sergiofornet
Copy link
Contributor Author

@AvinashKomaturi

The ref is created inside Slider component and passed to the container element via ref attribute:

<div css={SliderCSS} ref={sliderRef}>

Then that DOM element is used to add and remove the transitionend event listener.

I submitted a PR on this. #15

@AvinashKomaturi
Copy link

Thanks @sergiofornet

@DZuz14
Copy link
Owner

DZuz14 commented Nov 14, 2020

Fixed via #15 thank you!

@DZuz14 DZuz14 closed this as completed Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants