以实现用zepto.js实现文字上下无缝滚动为例;
主要是解决了zepto.js本身不支持animate动画函数的问题,zepto官方将animate写到了另外的一个类文件fx.js中。只要在zepto.js后引入fx.js即可使用animate动画函数。 fx.js可以去zepto官方的github上获取:https://github.com/madrobby/zepto/blob/master/src/fx.js
- <div class="notice">
- <div class="text">
- <ul style="margin-top: 0px;">
- <li>
- <a href="#">TODO</a>
- </li>
- <li>
- <a href="#">TODO</a>
- </li>
- <li>
- <a href="#">TODO</a>
- </li>
- </ul>
- </div>
- </div>
- <script type="text/javascript">
- $(function(){
- setInterval('autoScroll(".notice .text")',3000);
- });
- function autoScroll(obj){
- $(obj).find("ul").animate({
- marginTop : "-1rem"
- },500,function(){
- $(this).css({marginTop : "0px"}).find("li").slice(0, 1).appendTo($(this));
- })
- }
- </script>
复制代码
|