列表上下無縫滾動
阿新 • • 發佈:2017-12-18
上下 true into 輪播 app mouse num scrip var
var innerHeight = $(window).innerHeight(); $(".block").height(innerHeight - 190); //設定高度 var Timeobj, //儲存定時器 setDate_val=500, //定時器輪播時間 animateDate_val=100; //列表輪播時間 var FunInt=function(){ var blockHeight=$(‘.block‘).parent().innerHeight(); if(blockHeight==0){ blockHeight=$(‘.block‘).innerHeight(); } var blockChildren_Number=$(‘.block‘).children().length; var blockChildren_Height=$(‘.block‘).children(‘li‘).eq(0).innerHeight(); blockHeight=parseInt(blockHeight/blockChildren_Height)*blockChildren_Height; //基於LI高度的倍數高度 if(blockHeight<(blockChildren_Number*blockChildren_Height)){ $(‘.block‘).height(10000).parent().height(blockHeight).css({overflow:‘hidden‘}); var marginTop=parseInt($(‘.block‘).css(‘margin-top‘)); var nuberVal=(blockChildren_Number*blockChildren_Height)-blockHeight; nuberVal=-nuberVal; if(marginTop<0){ var kl_li_obj=$(‘.block‘).children().eq(0).clone(true); $(‘.block‘).children().eq(0).remove(); $(‘.block‘).append(kl_li_obj); $(‘.block‘).css({marginTop: marginTop+blockChildren_Height}, animateDate_val); }else{ $(‘.block‘).animate({marginTop: marginTop-blockChildren_Height}, animateDate_val); } } }; Timeobj=setInterval(FunInt,setDate_val); $(".block li").mouseenter(function(event) { clearInterval(Timeobj); }); $(".block").mouseleave(function(event) { Timeobj=setInterval(FunInt,setDate_val); });
列表上下無縫滾動