splide-extension-auto-scroll icon indicating copy to clipboard operation
splide-extension-auto-scroll copied to clipboard

pause(), play() methods are not working?

Open kumardeepakme opened this issue 1 year ago • 6 comments

Checks

  • [X] Not a duplicate.
  • [X] Not a question, feature request, or anything other than a bug report directly related to Splide. Use Discussions for these topics: https://github.com/Splidejs/splide/discussions

Version

v0.5.3

Description

Methods of splide-extension-auto-scroll are not working. Below is sample code for reference.

NOTE: @splidejs/splide = 4.1.4 @splidejs/splide-extension-auto-scroll = v0.5.3

import { Splide } from "@splidejs/splide";
import { AutoScroll } from "@splidejs/splide-extension-auto-scroll";

const carousel = new Splide(document.querySelector(".splide"), {
  type: "loop",
  gap: "20px",
  drag: "free",
  pagination: false,
  arrows: false,
  autoScroll: {
    speed: -0.5,
    pauseOnHover: false,
    pauseOnFocus: false,
  },
});
carousel.mount({ AutoScroll });

// !!! NOT WORKING !!!
/** Should ideally pause the carousel, but it is not?? */
carousel.Components.AutoScroll.pause();

Reproduction Link

https://codesandbox.io/p/devbox/splide-autoscroll-issue-cgg4v4

Steps to Reproduce

N/A

Expected Behaviour

Should pause & play with respective methods.

kumardeepakme avatar Jan 09 '24 10:01 kumardeepakme

Any update on this issue? @NaotoshiFujita OR @korneliusz-buczkowski-lemisoft

kumardeepakme avatar Feb 02 '24 12:02 kumardeepakme

is this project dead or what? 😡

kumardeepakme avatar Feb 17 '24 07:02 kumardeepakme

I think it is because you are calling it inmediately after mounting it, I replicated your issue but then wrapped inside a setTimeOut function and it worked

`function createSlider() { var splide = new Splide('.splide', { type: 'loop', drag: 'free', focus: 'center', direction: 'ttb', height: '435px', arrows: false, autoScroll: { speed: 1, }, });

splide.mount(window.splide.Extensions);

setTimeout(() => { splide.Components.AutoScroll.pause(); }, 3000); } window.addEventListener('DOMContentLoaded', createSlider);`

Maybe if you don't want it to play on load, you should use the intersection extension

natirivero avatar Feb 24 '24 14:02 natirivero

Why is there a need to employ setTimeout for running the methods? It should be the default functionality, especially when it's already loading after DOMContentLoaded. Regardless, I have decided not to use Splide anymore. 🙏

kumardeepakme avatar Feb 25 '24 05:02 kumardeepakme

It was just a quick test but Splide also have hooks, maybe one of those would work. Anyway, it's ok if you prefer to use a different tool :)

El El dom, 25 de feb. de 2024 a la(s) 12:24 a. m., Kumar Deepak < @.***> escribió:

Why is there a need to employ setTimeout for running the methods? It should be the default functionality, especially when it's already loading after DOMContentLoaded. Regardless, I have decided not to use Splide anymore. 🙏

— Reply to this email directly, view it on GitHub https://github.com/Splidejs/splide-extension-auto-scroll/issues/15#issuecomment-1962818191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP2Q272HQBNVAHQJPRKN7WLYVLDHBAVCNFSM6AAAAABBS3EOUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSHAYTQMJZGE . You are receiving this because you commented.Message ID: @.***>

natirivero avatar Feb 26 '24 02:02 natirivero

I also couldn't use those methods, so I used useToggleButton instead. 😛

autoScroll: {
  useToggleButton: true
}

https://codepen.io/ekkun/pen/ExJZbGQ

ekkun avatar Mar 19 '24 10:03 ekkun