Skip to content
This repository was archived by the owner on May 22, 2019. It is now read-only.
Open
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
63 changes: 40 additions & 23 deletions jquery.blueberry.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* EDITED : By Ganbin 19.02.2013
* Avoid the bug when you click quickly multi time on a image in the pager
* Before it cause a speed up of the animation. Now with this code,
* a timer is set that the user can't click on another image before waiting 700 milliseconds.
*
*/

(function($){
Expand Down Expand Up @@ -72,31 +78,41 @@
pager = $('.pager li', obj);
pager.eq(current).addClass('active');
}

//rotate to selected slide on pager click

// ADDITION 19.02.2013
// ADDITION TO Prevent multiClick on the pager
var onClickFunction = function() {
$('a', pager).unbind('click',onClickFunction); // ADDITION TO Prevent multiClick on the pager
//stop the timer
clearTimeout(obj.play);
//set the slide index based on pager index
next = $(this).parent().index();
//rotate the slides
rotate();

window.setTimeout(function(){$('a', pager).bind('click',onClickFunction)},700);// ADDITION TO Prevent multiClick on the pager

return false;
}
//rotate to selected slide on pager click
if(pager){
$('a', pager).click(function() {
//stop the timer
clearTimeout(obj.play);
//set the slide index based on pager index
next = $(this).parent().index();
//rotate the slides
rotate();
return false;
});
$('a', pager).bind('click',onClickFunction); // ADDITION TO Prevent multiClick on the pager
}

// STOP OF THE ADDITION 19.02.2013

//primary function to change slides
var rotate = function(){
//fade out current slide and remove active class,
//fade in next slide and add active class

slides.eq(current).fadeOut(o.duration).removeClass('active')
.end().eq(next).fadeIn(o.duration).addClass('active').queue(function(){
//add rotateTimer function to end of animation queue
//this prevents animation buildup caused by requestAnimationFrame
//rotateTimer starts a timer for the next rotate
rotateTimer();
$(this).dequeue()
$(this).dequeue();
});

//update pager to reflect slide change
Expand All @@ -109,6 +125,7 @@
//set next as first slide if current is the last
current = next;
next = current >= slides.length-1 ? 0 : current+1;

};
//create a timer to control slide rotation interval
var rotateTimer = function(){
Expand Down Expand Up @@ -144,33 +161,33 @@
//bind setsize function to window resize event
$(window).resize(function(){
setsize();
});

});


//Add keyboard navigation
//Add keyboard navigation

if(o.keynav){
$(document).keyup(function(e){
$(document).keyup(function(e){

switch (e.which) {
switch (e.which) {

case 39: case 32: //right arrow & space
case 39: case 32: //right arrow & space

clearTimeout(obj.play);
clearTimeout(obj.play);

rotate();
rotate();

break;
break;


case 37: // left arrow
clearTimeout(obj.play);
next = current - 1;
rotate();
rotate();

break;
}
}

});
}
Expand Down