From 8aa116b1e37cf696486fdcd75f95eed0869b40bb Mon Sep 17 00:00:00 2001 From: Lee Carmichael Date: Wed, 5 Sep 2012 10:56:43 -0500 Subject: [PATCH 1/5] cleaned up handling of timeout events to make sure multiples don't get created causing a speed up of slide display --- jquery.blueberry.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/jquery.blueberry.js b/jquery.blueberry.js index 7c0a032..ac5f97e 100644 --- a/jquery.blueberry.js +++ b/jquery.blueberry.js @@ -77,7 +77,7 @@ if(pager){ $('a', pager).click(function() { //stop the timer - clearTimeout(obj.play); + clearTimer(); //set the slide index based on pager index next = $(this).parent().index(); //rotate the slides @@ -110,13 +110,26 @@ current = next; next = current >= slides.length-1 ? 0 : current+1; }; + //create a timer to control slide rotation interval var rotateTimer = function(){ + // clean up everyone do their share to avoid a + // crap load of timeouts floating around + clearTimer(); + obj.play = setTimeout(function(){ //trigger slide rotate function at end of timer rotate(); }, o.interval); }; + + var clearTimer = function() { + if ( obj.play ) { + clearTimeout(obj.play); + obj.play = null; + } + } + //start the timer for the first time rotateTimer(); @@ -125,7 +138,7 @@ if(o.hoverpause){ slides.hover(function(){ //stop the timer in mousein - clearTimeout(obj.play); + clearTimer(); }, function(){ //start the timer on mouseout rotateTimer(); From d9fbe32b9e4b94fdb74468141966f2f8ab0a3ba2 Mon Sep 17 00:00:00 2001 From: Lee Carmichael Date: Fri, 14 Sep 2012 12:35:29 -0500 Subject: [PATCH 2/5] added start and stop events to library -upgraded example to jquery 1.7.2 --- index.html | 4 ++-- jquery.blueberry.js | 45 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 25e2d96..2f712a1 100644 --- a/index.html +++ b/index.html @@ -82,12 +82,12 @@ --> - + diff --git a/jquery.blueberry.js b/jquery.blueberry.js index ac5f97e..6c1aae4 100644 --- a/jquery.blueberry.js +++ b/jquery.blueberry.js @@ -130,20 +130,30 @@ } } + var setHoverPause = function() { + if(o.hoverpause){ + console.log('setting up hover pause'); + slides.hover(function(){ + //stop the timer in mousein + clearTimer(); + }, function(){ + //start the timer on mouseout + rotateTimer(); + }); + } + } + + var clearHover = function() { + if (o.hoverpause) { + console.log('removing hoverpause'); + slides.unbind('mouseenter mouseleave'); + } + } + //start the timer for the first time rotateTimer(); - //pause the slider on hover - //disabled by default due to bug - if(o.hoverpause){ - slides.hover(function(){ - //stop the timer in mousein - clearTimer(); - }, function(){ - //start the timer on mouseout - rotateTimer(); - }); - } + setHoverPause(); //calculate and set height based on image width/height ratio and specified line height var setsize = function(){ @@ -189,6 +199,19 @@ } + // add stop and start events + $(this).on('blueberry.stop', function(e) { + console.log('stop the fecking blueberry'); + clearTimer(); + clearHover(); + }); + + $(this).on('blueberry.start', function(e) { + console.log('start the blueberry'); + rotateTimer(); + setHoverPause(); + }); + }); } }); From 1ba9582c8633de81acf81cfb7af127a336f976b6 Mon Sep 17 00:00:00 2001 From: Lee Carmichael Date: Fri, 14 Sep 2012 12:37:21 -0500 Subject: [PATCH 3/5] removed debugging statements --- jquery.blueberry.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/jquery.blueberry.js b/jquery.blueberry.js index 6c1aae4..1b24f34 100644 --- a/jquery.blueberry.js +++ b/jquery.blueberry.js @@ -132,7 +132,6 @@ var setHoverPause = function() { if(o.hoverpause){ - console.log('setting up hover pause'); slides.hover(function(){ //stop the timer in mousein clearTimer(); @@ -145,7 +144,6 @@ var clearHover = function() { if (o.hoverpause) { - console.log('removing hoverpause'); slides.unbind('mouseenter mouseleave'); } } @@ -201,13 +199,11 @@ // add stop and start events $(this).on('blueberry.stop', function(e) { - console.log('stop the fecking blueberry'); clearTimer(); clearHover(); }); $(this).on('blueberry.start', function(e) { - console.log('start the blueberry'); rotateTimer(); setHoverPause(); }); From 3e35dc41fa7d2fa04c2273bd2caecd6c4b4443a3 Mon Sep 17 00:00:00 2001 From: Lee Carmichael Date: Tue, 25 Sep 2012 16:46:24 -0500 Subject: [PATCH 4/5] fix next/current math on keyleft nav --- jquery.blueberry.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/jquery.blueberry.js b/jquery.blueberry.js index 1b24f34..a3cbfcb 100644 --- a/jquery.blueberry.js +++ b/jquery.blueberry.js @@ -167,34 +167,26 @@ setsize(); }); - - //Add keyboard navigation - - if(o.keynav){ + if(o.keynav){ $(document).keyup(function(e){ - switch (e.which) { - case 39: case 32: //right arrow & space - - clearTimeout(obj.play); - + clearTimer(); rotate(); - break; - - - case 37: // left arrow - clearTimeout(obj.play); - next = current - 1; + + case 37: // left arrow + clearTimer(); + // feels like rotate should only be in charge of current/next + // and should update it to take direction parameter but + // this has least amount of impact + next = current - 1 < 0 ? slides.length -1 : current - 1; rotate(); - - break; + break; } - - }); - } + }); + } // add stop and start events From f3c7abe1a19f72c88f6b61edc9ba4b6a30f27e24 Mon Sep 17 00:00:00 2001 From: Lee Carmichael Date: Wed, 26 Sep 2012 08:32:10 -0500 Subject: [PATCH 5/5] prevented key events from changing slides on form inputs --- form.html | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 form.html diff --git a/form.html b/form.html new file mode 100644 index 0000000..d439c65 --- /dev/null +++ b/form.html @@ -0,0 +1,133 @@ + + + + +Blueberry - A simple, fluid, responsive jQuery image slider. + + + + + + + + + + + + + + + + +
+
+ + + +
+
    +
  • +
  • +
  • +
  • +
+
+ + +
+
+

+

+ select: + +
+
+
+
+ + +