jQuery scroll on hover

Posted by Happy on Stack Overflow See other posts from Stack Overflow or by Happy
Published on 2010-06-15T08:37:28Z Indexed on 2010/06/15 8:42 UTC
Read the original article Hit count: 684

Filed under:
|

HTML:

<body>
<div class="top-corner"></div> // absolute, top: 0
<div class="bottom-corner"></div> // absolute, bottom: 0
<a href="#" class="top-link">top</a> // fixed, top 50%, left 0
<a href="#" class="bottom-link">bottom</a> // fixed, top 60%, left 0
<div style="padding: 1500px 0;"></div> // for scroll test
</body>

Using scrollto plugin http://demos.flesler.com/jquery/scrollTo/

JS

$(".top-link").hover(function(){
    $("body").scrollTo($(".top-corner"), 3000);
},function(){
    // stop on unhover
});
$(".bottom-link").hover(function(){
    $("body").scrollTo($(".bottom-corner"), 3000);
},function(){
    // stop on unhover
});

Animation works on hover. How to stop it on unhover?

Thanks.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about scroll