开发者

How to smooth scrolling using jquery

I am using scrollTop to scroll through content div using this

    v开发者_开发百科ar container = $('#content');
    container.scrollTop(
        $('#topic-' + id).offset().top - container.offset().top
    );

    container.scrollTop(
        container.scrollTop() + $('#topic-' + id).offset().top - container.offset().top
    );

It works. But the scrolling is hard on the eyes. Is there any way to ease the transistion.

I appreciate any help.


From the jquery API ...

You need to use the scrolltop as a method in the animation. i.e. :

.animate({scrollTop:0}, 2000, 'ease')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜