0
$(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!

4

1 回答 1

1
$(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

于 2012-08-16T09:10:10.373 回答