2012-02-04 3 views
1
<div class="page"> 
     div content 
</div> 

<script> 

if(scroll mouse up while hovering #page) 
$('.page').animate({'left':'+40px'}); 

if(scroll mouse down while hovering #page) 
$('.page').animate({'left':'-40px'}); 

</script> 

私は上記の例のようにしたいと思います。誰か助けてくれますか?アニメーションをトリガーするにはdivでマウススクロールを使用しますか?

+0

var tempScrollTop, currentScrollTop = 0; $('#div').scroll(function() { currentScrollTop = $('#div').scrollTop(); if (tempScrollTop < currentScrollTop) { // UP } else if (tempScrollTop > currentScrollTop) { // DOWN } tempScrollTop = currentScrollTop; } 

コメントから撮影します「何かのようなもの」あなたの質問のどれも具体的な質問をしていないのはなぜですか? –

答えて

2

あなたはthis mousewheel pluginを使用して、することができます

$('.page').mousewheel(function(event, delta) { 
    event.preventDefault(); // if you want to prevent the window from scrolling 

    $(this).animate({left: (delta>0 ? '+' : '-')+'40px'}); 
}); 
+0

ありがとう、完璧に動作します! –

0

あなたがアップに検出することができますので、のようなネイティブscroll() jQueryの機能をスクロールダウン:http://api.jquery.com/scroll/

関連する問題