2012-08-16 29 views
0
$(document).scroll(function() { 

var distanceLeft = $(document).scrollLeft(); 

if(distanceLeft > 7200) 
{ 
$('#element').animate({height: 421, top: 55}, 1500); 
} 

嗨 我动画元素时滚动左达到7200多,我将如何扭转这种如果是小于7200回到原来的位置,请任何帮助将是惊人的感谢信您!向左滚动距离触发jQuery的CSS

回答

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); 
    } 
} 

把原来的值在palceholders

+0

非常感谢你这就是真正的帮助!工作一种享受! – gilesadamthomas 2012-08-16 09:31:44