Front-End & Daily

[FlexSlider 2] How to fix the issue where the slider stops when the window loses focus

[FlexSlider 2] How to fix the issue where the slider stops when the window loses focus

Here's how to fix the issue where the slider stops when the window loses focus while displaying the jQuery slider plugin "FlexSlider 2" on a PC.

Sample of the stopping issue

Open it on a PC and try changing focus to a different window.

You'll notice it stops.

This seems to be a FlexSlider specification, but I'll show you how to prevent it from stopping.

Solution

To prevent the slider from stopping even when the window is not in focus

Around line 1145 of flexslider.js

Comment out the following code.

// Ensure the slider isn't focussed if the window loses focus.
$( window ).blur( function ( e ) {
  focused = false;
}).focus( function ( e ) {
  focused = true;
});

Like this:

// Ensure the slider isn't focussed if the window loses focus.
//$( window ).blur( function ( e ) {
//  focused = false;
//}).focus( function ( e ) {
//  focused = true;
//});

Here's an example with this applied; it should no longer stop.

If you cannot load the iframe correctly, click here.

Comments

We also welcome reports such as 'It worked!'

After reviewing the content, we will publish it, omitting personal information.

Enter your name and email address

Please enter if you would like a reply by email.

We will not disclose any personal information provided. It will only be used for replies.

It will be sent directly. Please confirm and click 'Send'.

If this was helpful, we'd appreciate your support!
Any support received will be used for childcare.

Send support via OFUSE


Or support by buying something from the buttons below
(You don't have to buy the linked product.)

Amazon

楽天市場

Yahoo!ショッピング

PR

As an Amazon Associate, 'Ken' earns from qualifying purchases.

Share

Share on Twitter Share on Facebook Share on LINE Share on Hatena Bookmark