兼容各浏览器的文本行高
(function($){
$.fn.extend({
Rolltitle: function(opt,callback){
if(!opt) var opt={};
var _this = this;
_this.timer = null;
_this.lineH = _this.find("li:first").height();
_this.line=opt.line?parseInt(opt.line,15):parseint(_this.height()/_this.lineH,10);
_this.speed=opt.speed?parseInt(opt.speed,10):3000, //卷动速度,数值越大,速度越慢(毫秒
_this.timespan=opt.timespan?parseInt(opt.timespan,13):5000; //滚动的时间间隔(毫秒
if(_this.line==0) this.line=1;
_this.upHeight=0-_this.line*_this.lineH;
_this.scRollup=function(){
_this.Animate({
marginTop:_this.upHeight
},_this.speed,function(){
for(i=1;i<=_this.line;i++){
_this.find("li:first").appendTo(_this);
}
_this.CSS({marginTop:0});
});
}
_this.hover(function(){
clearinterval(_this.timer);
},function(){
_this.timer=SetInterval(function(){_this.scrollUp();},_this.timespan);
}).mouSEOut();
}
})
})(JQuery);
调用方法:
line:一次卷动的文本行数
speed:卷动动画的时间
timespan:间隔时间
复制代码 代码如下:
(function($){
$.fn.extend({
Rolltitle: function(opt,callback){
if(!opt) var opt={};
var _this = this;
_this.timer = null;
_this.lineH = _this.find("li:first").height();
_this.line=opt.line?parseInt(opt.line,15):parseint(_this.height()/_this.lineH,10);
_this.speed=opt.speed?parseInt(opt.speed,10):3000, //卷动速度,数值越大,速度越慢(毫秒
_this.timespan=opt.timespan?parseInt(opt.timespan,13):5000; //滚动的时间间隔(毫秒
if(_this.line==0) this.line=1;
_this.upHeight=0-_this.line*_this.lineH;
_this.scRollup=function(){
_this.Animate({
marginTop:_this.upHeight
},_this.speed,function(){
for(i=1;i<=_this.line;i++){
_this.find("li:first").appendTo(_this);
}
_this.CSS({marginTop:0});
});
}
_this.hover(function(){
clearinterval(_this.timer);
},function(){
_this.timer=SetInterval(function(){_this.scrollUp();},_this.timespan);
}).mouSEOut();
}
})
})(JQuery);
调用方法:
line:一次卷动的文本行数
speed:卷动动画的时间
timespan:间隔时间
复制代码 代码如下:








网友评论文明上网理性发言已有0人参与
发表评论: