0

此代码用于向下/向上导航页面。一切正常,我只想让它更轻松一些。一些看起来更好一点的动画。有任何想法吗??

<script type="text/javascript">

$(函数(){

function scroll(direction) {

    var scroll, i,
            positions = [],
            here = $(window).scrollTop(),
            collection = $('.part');

    collection.each(function() {
        positions.push(parseInt($(this).offset()['top'],10));
    });

    for(i = 0; i < positions.length; i++) {
        if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
        if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
    }

    if (scroll) {
        $.scrollTo(scroll, {
            duration: 350       
        });
    }

    return false;
}

$("#next,#prev").click(function() {        
    return scroll($(this).attr('id'));        
});

$(".scrolltoanchor").click(function() {
    $.scrollTo($($(this).attr("href")), {
        duration: 350
    });
    return false;
});

});

4

1 回答 1

0

试试这个: http: //gsgd.co.uk/sandbox/jquery/easing/

于 2012-10-07T21:20:09.823 回答