Streaming live at 10am (PST)

Slider swipe and autoplay on mobile

Can you set a slider to play automatically on mobile but NOT on desktop?

Thanks!


Here is my site Read-Only:
https://preview.webflow.com/preview/norml?utm_medium=preview_link&utm_source=designer&utm_content=norml&preview=ca82fc1bc565ceadae8a7aca50b8d9bc&mode=preview

Here is the published site:

For now only by custom code. Set autoplay to true (On webflow designer) and set data-autoplay (Js attribute) to false (0) by custom code.

Copy-Paste this code before body (Under page setting).
** This code stop all sliders on the page.

<script>
	/* if screen width is more than 767px */
  if (window.innerWidth > 767) {
    stopSliderAutoPlay();
  }

  function stopSliderAutoPlay() {
    var slider, i;
    slider = document.querySelectorAll(".w-slider");
    for (i = 0; i < slider.length; i++) {
    	/* stop webflow slider autoplay */ 
      slider[i].setAttribute("data-autoplay", "0");
    }
  }
</script>

Result: Autoplay on mobile only.

Worked like a charm. Thank you very much!