Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Added option to avoid slider stopping on blur #89

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ in your CSS.
|keyboardNav|`true`|Toggle keyboard navigation|
|previousNavSelector|`''`|Selector for custom previous nav element|
|nextNavSelector|`''`|Selector for custom next nav element|
|stopOnBlur|`true`|Prevent the slider to stop when browser lost its focus|
|classes|`{...}`|List of classes to be used by slider. Probably shouldn't be changed|

## Events
Expand Down
11 changes: 7 additions & 4 deletions ideal-image-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ var IdealImageSlider = (function() {
keyboardNav: true,
previousNavSelector: '',
nextNavSelector: '',
stopOnBlur: true,
classes: {
container: 'ideal-image-slider',
slide: 'iis-slide',
Expand Down Expand Up @@ -647,9 +648,11 @@ var IdealImageSlider = (function() {
this.settings.onStart.apply(this);

// Stop if window blur
window.onblur = function() {
this.stop();
}.bind(this);
if (this.settings.stopOnBlur) {
window.onblur = function() {
this.stop();
}.bind(this);
}
};

Slider.prototype.stop = function() {
Expand Down Expand Up @@ -829,4 +832,4 @@ var IdealImageSlider = (function() {
Slider: Slider
};

})();
})();