/** * 内容滚动效果 * @boxobj1 外层固定宽度的box * @boxobj2 内层无限长度的box * @numobj 小按钮 * @direction 滚动方向[默认横向2] * @speed  滚动速度 */ function crossslider(boxobj1, boxobj2, numobj, direction, speed){ direction = direction ? direction : 2; var index = 0; var adtimer; if( numobj ){ var len = numobj.length; numobj.mouseover(function(){ index = numobj.index(this); showimg(index,boxobj1,boxobj2,numobj,direction); }).eq(0).addclass("on"); }else{ //没有小按钮 var len = boxobj2.children().length; } boxobj1.mouseover(function(){ clearinterval(adtimer); }).mouseout(function(){ adtimer = setinterval(function(){ showimg(index,boxobj1,boxobj2,numobj,direction); index++; if(index==len){index=0} },speed); }).trigger("mouseout"); } function showimg(index,boxobj1,boxobj2,numobj,direction){ if( direction == 2 ){ var addistance = boxobj1.width(); boxobj2.stop(true).animate({"left" : -addistance*index},1000); }else{ var addistance = boxobj1.height(); boxobj2.stop(true).animate({"top" : -addistance*index},1000); } numobj && numobj.removeclass("on").eq(index).addclass("on"); } /*--------------------index------------------------------*/ function scrollresizew(obj){ console.log(obj); var obj = obj; window.onscroll = window.onresize= function(){ if( obj.length > 0 ) setbanliwidth(obj); //弹出层 } } function setbanliwidth(obj){ var clientwidth = document.body.clientwidth; console.log(obj + clientwidth); obj.css({'width':clientwidth}); }