$(document).ready(function(e) {
$('span#pijlr').click(function(e) {
var slide = 500;
var variable = $('#gallcont').css('left');
var urechts = "-1000px";
if(variable > urechts) {
$('#gallcont').animate({'left': '-=' +slide+ 'px'},'fast','linear');
}
});
$('span#pijll').click(function(e) {
var slide = 500;
var variable = $('#gallcont').css('left');
var ulinks = "0px";
if(variable < ulinks) {
$('#gallcont').animate({'left': '+=' +slide+ 'px'},'fast','linear');
}
});
});
This code i wrote for a simple slide gallery i made. All works fine except when i fast click the arrow buttons. It will go beyond the values i set up (urechts and ulinks).
I tried putting 'stop()' before the .animate, but it didn't help. Hope you guys can give me some advise on how to solve this. Thanks in advance!
What about adding some conditional, like this:
$('span#pijlr').click(function(e) {
if (!$('#gallcont').is(':animated')) {
var slide = 500;
var variable = $('#gallcont').css('left');
var urechts = "-1000px";
if(variable > urechts) {
$('#gallcont').animate({'left': '-=' +slide+ 'px'},'fast','linear');
}
}
});
Something like that will nullify the event while the slide is animating..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With