animatescroll.js是一款非常实用的动画滚动jQuery插件。你可以使用该插件制作返回顶部效果,平滑滚动到某个指定元素等。它支持30+种不同的easing过渡动画,并且兼容IE8浏览器。
安装
可以通过bower来安装该动画滚动插件。
bower install animatescroll                  
                
                使用方法
使用该动画滚动插件需要在页面中引入jquery和animatescroll.js文件。
<script src="path/to/jquery.min.js"></script>
<script src="path/to/animatescroll.js"></script>                  
                
                HTML结构
该动画滚动的基本HTML结构如下:
<html>
    <head>
        <script src="path/to/jquery.min.js"></script>
        <script src="path/to/animatescroll.js">
    </head>
    <body>
        <div id="section-1">这里是你需要滚动到的元素<div>
        /*
         * 你可以像下面这样来调用插件,但是最好是通过事件监听来调用
         */
        <a onclick="$('[jquery selector]').animatescroll([options]);">Go to Element</a>
    </body>
</html>
                
                初始化插件
处理上面的onclick方法调用之外,你可以在页面DOM元素加载完毕之后,可以通过animatescroll()方法来初始化该插件。
$('body').animatescroll();
//自定义参数
$('body').animatescroll({scrollSpeed:2000,easing:'easeInOutBack'});
                
                配置参数
该动画滚动插件有6个可用的配置参数:
- 
easing:滚动的easing效果,支持的easing效果可以参考easings.net
- 
scrollSpeed:滚动的速度。
- 
padding:调整滚动的上下间距。
- 
element:你想滚动到的元素。默认为body。
- 
onScrollStart:回调函数,在开始滚动时触发。$('#target-element').animatescroll({onScrollStart:function(){alert('scroll started')}});
- 
onScrollEnd:回调函数,在结束滚动时触发。$('#target-element').animatescroll({onScrollEnd:function(){alert('scroll ended')}});
animatescroll.js动画滚动插件的github地址为:https://github.com/ramswaroop/animatescroll.js
版权声明
版权说明: 仅限用于学习和研究目的;不得将上述内容用于商业和非法用途!否则一切后果自负。我们非常重视版权问题,如有侵权请邮件至(171373236#qq.com)与我们联系处理,敬请谅解!


 
                    



















