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

Swipe between slides not work correctly when autoplay is enabled #298

Closed
martin-badin opened this issue Oct 7, 2018 · 13 comments
Closed
Labels

Comments

@martin-badin
Copy link

Issue description: Hello, when I use autoplay and dragging function simultaneously the interval for autoplay isn't reset when a user swipe between slides. See example. Please, reset the interval when a user swipe between slides.

Demo link/slider setting: http://jsfiddle.net/p5wdjLn2/12/

Browser name && version: Chrome 69.0.3497.100
OS name && version: macOS Mojave 10.14

@Jack89ita
Copy link

I got the same problem and I was writing the same issue. Thank you for posting!

@martin-badin
Copy link
Author

martin-badin commented Oct 8, 2018

here is solution

for stop timer

function onPanStart (e) {
    if (running) { onTransitionEnd(); }

+   if (autoplay && animating) { stopAutoplayTimer(); }

    panStart = true;
    if (carousel) {
      caf(rafIndex);
      rafIndex = 0;
    }
    ...

and for start timer

function onPanEnd (e) {
    ...

    if (swipeAngle) { moveDirectionExpected = '?'; } // reset

+   if (autoplay && !animating) { setAutoplayTimer(); }
  }

please, implement this fix to next release

@Jack89ita
Copy link

This is how i fixed it:

slider.events.on('dragStart', carousel.stopAutoplay);
slider.events.on('touchstart', carousel.stopAutoplay);
slider.events.on('dragEnd', carousel.startAutoplay);
slider.events.on('touchEnd', carousel.startAutoplay);

stopAutoplay(){
  slider.pause();
},

startAutoplay(){
  slider.play();
},

Hope it helps!!

@ganlanyuan
Copy link
Owner

@martin-badin So you want the interval for autoplay start right after the touch end?
I think @Jack89ita's solutions is good for this.

@martin-badin
Copy link
Author

Yes, I want but this bug should be fixed in the package.

@ganlanyuan ganlanyuan added bug and removed question labels Oct 22, 2018
@ganlanyuan
Copy link
Owner

ganlanyuan commented Oct 22, 2018

Added in this commit.

@martin-badin
Copy link
Author

Thanks

@Jack89ita
Copy link

Hi @ganlanyuan thank you for fixing this, but how can i download this edited package?
thanks!

@ganlanyuan
Copy link
Owner

@Jack89ita This change is not published yet, so you won't be able to download via npm.
But you can still download it manually at the repository of this library.

@TitanFighter
Copy link
Contributor

@Jack89ita
npm install https://github.com/ganlanyuan/tiny-slider#10b15514f114b3ea1053a639aa5b449939ca334a
or
npm install ganlanyuan/tiny-slider

@Jack89ita
Copy link

@TitanFighter Thank you!

@dejvestrunc
Copy link

The bug is still showing when autoplayHoverPause is set as true

@saver174
Copy link

@martin-badin The bug is still here

version
"tiny-slider": "^2.9.1",

config
var slider = tns({
container: '.my-slider',
items: 3,
autoplay: true,
mouseDrag: true,
controls: false,
nav: false,
autoplayHoverPause: true,
autoplayButtonOutput: false
});

When I drag and hold with mouse on slide item and get out of slider with cursor, animation resume (animation should not resume when drag is hold)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants