question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autoplay option does not work in Safari

See original GitHub issue

Reproduce step:

  • Open a page with a Swiper with autoplaying.
  • Open that page in a second tab.
  • Play around with the second tab (click on the nextButton or prevButton).
  • Go back to the first tab and the autoplay does not work anymore, neither the nextButton nor prevButton works. However, clicking on the pagination still works.

My swiper options are:

new Swiper('.selector',
  { autoplay: 3000,
    pagination: '.swiper-pagination',
    nextButton: '.swiper__next-btn',
    prevButton: '.swiper__prev-btn' }

After investigating, here is what I could find:

  • s.animating is true when calling function s.slideNext()
  • s.animating is true because it is set to true when calling function s.slideTo() (at the end of the function). s.animating is intended to set back to false in the transitionEnd event’s callback. However, the callback for transitionEnd is not called when switching tab in Safari.

Additional info:

  • Swiper version: 3.3.1
  • Safari version: 9.0.3 (10601.4.4)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
damhonglinhcommented, Mar 2, 2016

My temporary solution is:

var homeBanner = new Swiper('.selector', {/* some options */});

(function fixSafariSwitchingTab() {
  if (!homeBanner.isSafari) return;

  $(window).focus(function() {
    if (homeBanner.animating) {
      homeBanner.animating = false;
      // restart autoplay
      homeBanner.stopAutoplay();
      homeBanner.startAutoplay();
    }
  });
})();
0reactions
nolimits4webcommented, Nov 13, 2017

Issue is closed because of outdated/irrelevant/not actual/needed more information/inactivity.

If this issue is still actual and reproducible for latest version of Swiper, please create new issue and fill the issue template correctly:

  • Clearly describe the issue including steps to reproduce when it is a bug.
  • Make sure you fill in the earliest version that you know has the issue.
  • Provide live link or JSFiddle/Codepen or website with issue
Read more comments on GitHub >

github_iconTop Results From Across the Web

Video auto play is not working in Safari and Chrome ...
I had this issue in Safari 11 where a background video (no audio) wouldn't play automatically. Adding muted and autoplay did the trick....
Read more >
Safari "Allow all auto-play" not working on Youtube playlist.
Open Youtube > Click Safari > Settings for this website > Change 'Auto-Play' setting to Allow always. Should work!. Show more Less. Reply ......
Read more >
[Video Autoplay] not working in Safari 15.5
Running in low power mode -> Full charged and plugged · 'Never auto-play' set in the Website tab of Safari's Preferences set on...
Read more >
HOW-TO: Enable Autoplay for Safari Users
1. Open Safari and navigate to Safari > Settings for This Website in the menu bar. 2. This will bring up a window...
Read more >
Fix HTML Video Autoplay Not Working
You've added a video tag to your website, set the video source, but it won't autoplay. Let's fix it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found