From 3c878fb23dcc7ca12aabcfa2239684d47b24dfc2 Mon Sep 17 00:00:00 2001 From: Gayantha Samaradiwakara Date: Fri, 21 Sep 2018 16:17:41 +0530 Subject: [PATCH 1/2] Slider freezes on tab switch. made it configurable from settings. Default is set to false, i.e. slider will not be freezed upon browser blur. --- src/js/lightslider.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/js/lightslider.js b/src/js/lightslider.js index 6d9c79f..d61b1fc 100644 --- a/src/js/lightslider.js +++ b/src/js/lightslider.js @@ -36,6 +36,7 @@ freeMove: true, swipeThreshold: 40, responsive: [], + freezeOnTabSwitch : false, /* jshint ignore:start */ onBeforeStart: function ($el) {}, onSliderLoad: function ($el) {}, @@ -874,13 +875,15 @@ } } - $(window).on('focus', function(){ - $this.auto(); - }); - - $(window).on('blur', function(){ - clearInterval(interval); - }); + if(settings.freezeOnTabSwitch){ + $(window).on('focus', function(){ + $this.auto(); + }); + + $(window).on('blur', function(){ + clearInterval(interval); + }); + } $this.pager(); $this.pauseOnHover(); From 3144a68c0a34a6854b4ad493d063afcfe4de4def Mon Sep 17 00:00:00 2001 From: Gayantha Samaradiwakara Date: Fri, 21 Sep 2018 16:40:51 +0530 Subject: [PATCH 2/2] added freezeOnTabSwitch to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 854cb32..c2595f4 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ add the Following code to the <head> of your document. enableDrag:true, freeMove:true, swipeThreshold: 40, + freezeOnTabSwitch : false, responsive : [],