最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - nanoScroller.js with smooth scrolling - Stack Overflow

programmeradmin1浏览0评论

I'm using the nanoScoller.js plugin to create custom scrollbars on a website. This works fine except it would be nice if it could perform some kind of easing / smooth scrolling. The plugin doesn't seem to have an option for this, I was wondering is there any other way this can be achieved?

$('.nano').nanoScroller({
    alwaysVisible: true
});

I'm using the nanoScoller.js plugin to create custom scrollbars on a website. This works fine except it would be nice if it could perform some kind of easing / smooth scrolling. The plugin doesn't seem to have an option for this, I was wondering is there any other way this can be achieved?

$('.nano').nanoScroller({
    alwaysVisible: true
});
Share Improve this question asked Mar 30, 2014 at 14:47 MAX POWERMAX POWER 5,45816 gold badges98 silver badges146 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

In case you want to use nanoScrollbar and still want to animate scroll, you can animate the content's default (browser) scrollbar and nanoScrollbar will animate the emulated slider as it listens to scroll events of content.

Below is the code for animating scroll to bottom

var el = $('.nano-content');
el.animate({ 'scrollTop': el[0].scrollHeight }, 'slow');

Hope this helps people who are looking for alternative solution.

nanoScroller uses native scrolling behavior, it does not emulate it. So, if browser does not support smooth scrolling, nanoScroller does not support it too. To make smooth scrolling you have to use custom scrollbar that emulates scrolling with animation/easing. There is a lot of scrollbar plugins that emulates scrolling (and supports scroll animation): jScrollPane, Malihu Custom Scrollbar, Perfect Scrollbar, slimScroll and others. You can check this document to pare scrollbars and select the one you need. Look at scrollbars with type "emulator"

发布评论

评论列表(0)

  1. 暂无评论