首页 > 其他 > 详细

无缝滚动插件

时间:2017-11-08 19:02:24      阅读:194      评论:0      收藏:0      [点我收藏+]
;(function($){  
    $.fn.moveUp=function(options){  
        var defaults = {//初始化参数  
            moveHeight:22,      
            time:2000     
        };   
        var opts =$.extend({},defaults,options);//扩展参数  
  
        var a=$(this);  
        var top=0;  
        var timer;  
        a.find(‘li‘).first().clone().appendTo(a);//克隆追加第一个子对象  
        timer=setInterval(moveUp,opts.time);  
        a.hover(function(){clearInterval(timer)},function(){timer=setInterval(moveUp,opts.time)});  
        var endHeight=a.height();//追加子对象后的总高度  
        function moveUp(){  
            top=top+opts.moveHeight;  
            if(top>=endHeight){  
                a.css(‘marginTop‘,‘0px‘);  
                top=opts.moveHeight;  
            }  
            a.stop().animate({‘marginTop‘:-top+‘px‘});  
            //document.title=a.css(‘marginTop‘);  
        }  
    }  
})(jQuery);

$(function(){
    $(‘ul‘).moveUp({moveHeight:22,time:2200});
})

 

技术分享

 

无缝滚动插件

原文:http://www.cnblogs.com/binmengxue/p/7805444.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!