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

Stop Autoplay on click #63

Closed
wants to merge 2 commits into from

Conversation

perdittmann
Copy link

@perdittmann perdittmann commented Oct 24, 2022

Introduces/changes the following functionalities:

  1. Autoplay stops when the user interacts (clicks/taps prev or next buttons or slider indicators)
    For the case that the design features a pause button shown onhover (to indicate the "pause on hover" functionality), the class "slider-nav-autopause" is removed
  2. Easier way to set the delay with which the indicators react

Introduces/changes the following functionalities:
1. Autoplay stops when the user interacts (clicks/taps prev or next buttons or slider indicators)
   Should the design feature a pause button shown onhover (to indicate the "pause on hover" functionality), the class "slider-nav-autopause" is removed
2. Easier way to set the delay with which the indicators react
@nicped
Copy link
Member

nicped commented Oct 24, 2022

Thank you for making the time to help improve Swiffy Slider.

I am not sure your changes are the way to go though.

You have added variables outside the swiffyslider instance which could cause a number of issues since the variables would be shared with your own script and other libraries or if you have more than one instance of sliders on the same page - since those variables are not instance dependent. The entire Swiffy slider script is 'stateless' and 'instance-less', so using variables like that would cause issues.

The reason the indicator delay is there is to avoid a huge amount of calls to handleIndicators method. It uses the scroll event listener and if you set the threshold to 0, the code is executed a lot of times causing the browser to use a lot of CPU. You can try to add a console.log inside handleIndicators and see what happens if you set it to 0.

If you really need to control the indicator delay, it should be working the same way as auto play intervals and animation thresholds using attributes - like the data-slider-nav-autoplay-interval attribute - and be read in the initSlider method. This way it will be configurable in markup (as the rest of the Swiffy Slider) and it would be instance specific. But I think it is wrong to have it as it will cause performance problems.

Auto stopping the player on click I can see a use for - also here I would go for a solution using a class like all other configuration - i.e. adding a .slider-nav-autostop option that would stop the player when something is clicked. I can give it a go later on using a class.

@perdittmann
Copy link
Author

perdittmann commented Oct 24, 2022 via email

@nicped nicped closed this Jul 5, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants