Reputation: 181
$(document).scroll(function() {
var distanceLeft = $(document).scrollLeft();
if( distanceLeft > 7200)
{
$('#element').animate({height: 421, top: 55}, 1500);
}
Hi I am animating an element when the scroll left reaches more than 7200, how would I reverse this if it was less than 7200 back to original position please any help would be amazing thank you!
Upvotes: 0
Views: 530
Reputation: 1020
$(document).scroll(function() {
var distanceLeft = $(document).scrollLeft();
var isLeft = false;
if (distanceLeft > 7200) {
isLeft = true;
$('#element').stop(true, false).animate({ height: 421, top: 55 }, 1500);
} else if (isLeft) {
isLeft = false;
$('#element').stop(true, false).animate({ height: origHeight, top: origTop }, 1500);
}
}
put the original values in the palceholders
Upvotes: 1