mmdevcodes / a11y-slider

Library for simple and accessible sliders
https://a11yslider.js.org/
MIT License
53 stars 8 forks source link

Should carousel stop autoplay when user’s reduce motion is true (prefers-reduced-motion: reduce) in OS? #45

Open Domchocolate opened 6 months ago

Domchocolate commented 6 months ago

It would be great if the carousel would stop autoplay when user’s reduce motion is true (prefers-reduced-motion: reduce) in OS?

I can get this to work but it removes the previous/next buttons so we’re left with the first slide visible and navigable.

`// Check if the user prefers reduced motion const prefersReducedMotion = window.matchMedia(‘(prefers-reduced-motion: reduce)’).matches;

// Set autoplay based on the user’s preference const autoplayEnabled = !prefersReducedMotion;

const slider = new A11YSlider(document.querySelector(‘.slider’), { adaptiveHeight: true, dots: true, arrows: true, autoplay: autoplayEnabled, autoplaySpeed: 5000 });`

Any ideas on how we get this to work?