>  기사  >  웹 프론트엔드  >  jquery 스크롤 광고 위아래로_jquery

jquery 스크롤 광고 위아래로_jquery

WBOY
WBOY원래의
2016-05-16 18:51:391256검색
复제대码 代码如下:

(function($){
$.fn.extend( {
rollList:function(옵션){
option=$.extend({
방향:"위",
단계:1,
시간:23
},옵션) ;
var step_coe,scroll_coe,score_coe;
if(option.direction=="up")
{
step_coe=1;
score_coe=1;
}else
{
step_coe=-1;
scroll_coe=-1;
score_coe=0
}
return this.each(function(){
var $this=$(this);
var _this=this; var itemHeight
var temp=$("
"); .css("overflow","hidden").children()
.appendTo(temp)
$this.append(temp.clone(true)).append(temp)
itemHeight= $this.children();
itemHeight=itemHeight.eq(1).offset().top-itemHeight.eq(0).offset().top
while($this.children(": last").offset().top-$this.offset().top<=$this.height())
$this.append(temp.clone(true));
varroll;
this.scrollTop=itemHeight*(1-score_coe);
roll=function (){
temp=setInterval(function(){
if(_this.scrollTop*scroll_coe>=itemHeight*score_coe)
{
_this.scrollTop=(_this.scrollTop-itemHeight)*scroll_coe;
}
_this.scrollTop =option.step*step_coe;

},option.time);
}
$this.hover(function(){
clearInterval(temp);
},function(){
roll();
});
롤();
});
}
})
}(jQuery));



调用如下:


复主代码 代码如下: $(elem).rollList();

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.