how stopping this scroll?
Hi,
I'm working with this script to do an ul scroll.
I don't know exactly how many li will do, but firstly I read the length and then I match this length to my ul.
By two buttons (prev and next) the animation go ahead and back, but when the li are finished the button is still active and the scroll go ahead.
How can I stop it and remove the button?
- totWidth = $(".img-slide li").size() * 100; // get ul total width
$(".img-slide").css("width", totWidth); // set ul total width
marginMax = 400 - totWidth; // right slide limit
move = 100; // move step
rest = totWidth - 400;
leftRest = 0;
$(".next").click(function() { //evento click su pulsante next
start = parseInt($(".img-slide").css("margin-left")); // current slide position
if (start > marginMax) {
newStart = parseInt(start) - move;
if(rest >= move){
$(".img-slide").animate({
marginLeft: newStart
}, 500);
rest = newStart - 400 + totWidth;
leftRest = totWidth - 400 - rest;
} else {
newStart = parseInt(start) - rest;
$(".img-slide").animate({
marginLeft: newStart
}, 500);
leftRest = totWidth - 400 - rest;
}
}
return false;
});
$(".prev").click(function() { //evento click su pulsante prev
start = parseInt($(".img-slide").css("margin-left"));
goBack = start + move;
if (start != 0) {
newStart = parseInt(start) + move;
if(leftRest > newStart){
$(".img-slide").animate({
marginLeft: goBack
}, 500);
rest = newStart - 400 + totWidth;
leftRest = totWidth - 400 - rest;
} else {
newStart = parseInt(start) + leftRest;
$(".img-slide").animate({
marginLeft: newStart
}, 500);
}
}
return false;
});
li = 100px
div mask = 400px
step = single element
Thanks a lot