;(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');
}
};
$.fn.moveLeft=function(options){
var defaults = {//初始化参数
moveWidth:100,
time:2000
};
var opts =$.extend({},defaults,options);//扩展参数
var a=$(this);
var left=0;
var timer;
a.find('li').first().clone().appendTo(a);//克隆追加第一个子对象
timer=setInterval(moveLeft,opts.time);
a.hover(function(){clearInterval(timer)},function(){timer=setInterval(moveLeft,opts.time)});
var endWidth=a.width();//追加子对象后的总高度
function moveLeft(){
left=left+opts.moveWidth;
if(left>=endWidth){
a.css('marginLeft','0px');
left=opts.moveWidth;
}
a.stop().animate({'marginLeft':-left+'px'});
//document.title=a.css('marginTop');
}
}
})(jQuery);
$(function(){
$('.demo ul').moveUp({moveHeight:22,time:2200});
$('.demo2 ul').moveLeft({moveWidth:100,time:2200});
})