1/* 2======示ä¾===== 3<style> 4body{margin:20px;} 5#focus{height:200px;width:500px;position:relative;margin:auto;border:5px solid #ccc;} 6.frame{width:100%;height:100%;overflow:hidden;} 7.frame .child{height:100%;float:left;} 8.nav{position:absolute;width:60px;height:20px;overflow:hidden;left:50%;bottom:5px;margin-left:-31px;border:1px solid #aaa;} 9.nav a{float:left;width:20px;height:20px;line-height:20px;font-size:12px;color:#000;text-align:center;background:#f5f5f5;} 10.nav a.now{background:#aaa;color:#fff;} 11.prev{right:30px;bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background:#f5f5f5;position:absolute;color:#000;font-size:12px;font-family:Arial;} 12.next{right:5px;bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background:#f5f5f5;position:absolute;color:#000;font-size:12px;font-family:Arial;} 13.title{height:30px;line-height:30px;float:left;} 14.count{height:30px;line-height:30px;float:right;} 15.count b{font-weight:normal;} 16.count em{font-style:normal;} 17</style> 18<div class="focus"><a href="javascript:;" class="prev"><</a><a href="javascript:;" class="next">></a> 19 <div class="frame"> 20 <div class="child" style="background:#faa;" title="c1"></div> 21 <div class="child" style="background:#afa;" title="c2"></div> 22 <div class="child" style="background:#aaf;" title="c3"></div> 23 <div class="child" style="background:#ffa;" title="c4"></div> 24 <div class="child" style="background:#aff;" title="c5"></div> 25 </div> 26 <div class="nav"> 27 <i>1</i> 28 <i>2</i> 29 <i>3</i> 30 <i>4</i> 31 <i>5</i> 32 </div> 33 <div class="title"></div> 34 <div class="count"><b></b>/<em></em></div> 35</div> 36<script> 37$('.focus .frame').mScroll({ 38 auto : 1, //èªå¨å¼å§ 39 direction : "h", //æ»å¨æ¹å,h横å,v纵å 40 dtype : "left", //æ£åæ¹å 41 isfocus : 0, //æ¯å¦ä½ä¸ºç¦ç¹å¾ 42 minsize : [ 43 { 44 width:0, 45 size:1 46 }, 47 { 48 width:1000, 49 size:4 50 } 51 ], //æå°æ°é 52 speed : 500, //æ»å¨é度 53 easing : "", //ç¼å²ç±»å 54 delay : 5000, //èªå¨æ»å¨é´é 55 nav : ".focus .nav i", //å¯¼èªæé® 56 event : "click", //å¯¼èªæé®äºä»¶ç±»å 57 scrollnav : 0, //å¯¼èªæ»å¨ 58nav_direction : "h", //å¯¼èªæ¹å,h横å,v纵å 59 prev : ".focus .prev", //åä¸ä¸ª 60 next : ".focus .next", //åä¸ä¸ª 61 index : ".focus .index", //å½ååºå· 62 count : ".focus .count b", //æ»æ° 63 title : ".focus .count em", //æ é¢ 64 arrow : 1, //æ¯å¦å转 65 cycle : 1, //æ¯å¦å¾ªç¯ 66 mousestop : 1, //é¼ æ åå ¥åæ¢ 67 mousewheel : 0, //å¼å¯æ»è½®äºä»¶ 68 touch : 0, //å¼å¯è§¦æ¸äºä»¶ 69 callback : function(idx){} //åè°å½æ° 70}); 71</script> 72=============== 73*/ 74//åéè§£é 75/* 76f=对象主ä½frame 77s=frameå æ»å¨å ç´ 78c=så åå ç´ 79n=导èªåå ç´ 80np=导èªç¶å ç´ 81ns=导èªå æ»å¨å ç´ 82w,h=æ»å¨è·ç¦» 83ww,hh=åå§æ»é¿åº¦ 84size=så åå ç´ åå§æ°é 85iv,ti=宿¶å¨ 86sw=æ§å¶å¼å ³ 87idx=å½ååºå· 88cm=så åå ç´ è¾¹è· 89*/ 90(function($) { 91 $.fn.mScroll = function(options) { 92 var opts = $.extend({},$.fn.mScroll.defaults,options); 93 this.each(function(){ 94 //åå§ååé 95 var f = $(this); 96 var s,c,n,np,ns,w,ww,h,hh,wn,hn,size,iv,ti,sw=1,sw1=0,idx=0,ids=0,idx1=0,cm=0; 97 //var tt=5000; 98 99 //æ§å¶å¤æåå§å 100 if(opts.cycle==0){opts.auto=0;} 101 if(opts.touch==1){ 102 opts.minsize=1; 103 opts.mousestop=0; 104 opts.mousewheel=0; 105 } 106 107 function getMinsize(){ 108 if(typeof(opts.minsize)=="object"){ 109 var minsize=0;//var minsize=opts.minsize[0].size; 110 for(var i=0;i<opts.minsize.length;i++){ 111 var mz=new Object(opts.minsize[i]); 112 if($(window).width()>mz.width){ 113 minsize=mz.size; 114 } 115 } 116 return minsize; 117 } 118 else{ 119 return opts.minsize; 120 } 121 } 122 123 if(f.children().size==1){return false;} 124
125 //çæscrollç»æï¼èµå¼s 126 if(f.children().is("ul") && f.children().length>1 && !f.children().hasClass("child")){ 127 f.children().addClass("scroll"); 128 } 129 else{ 130 f.children().wrapAll("<div class='scroll' style='height:100%;'></div>"); 131 } 132 s = f.find(".scroll"); 133 134 //åå§åsize 135 size=s.children().length; 136 137 138 //å建céåï¼èµå¼c 139 if(opts.cycle==1 && size>getMinsize()){s.append(s.html());} 140 c = s.children(); 141 142 //åå§åå¯¼èª 143 n = $(opts.nav); 144 if(opts.scrollnav){ 145 wn = parseInt(n.outerWidth()+parseInt(n.css("margin-left"))+parseInt(n.css("margin-right"))); 146 hn = parseInt(n.outerHeight()+parseInt(n.css("margin-top"))+parseInt(n.css("margin-bottom"))); 147 np= $(opts.nav).parent(); 148 n.wrapAll("<div class='scroll' style='height:100%;'></div>"); 149 n.width(wn); 150 ns=np.find(".scroll"); 151 if(opts.nav_direction=="h"){ 152 ns.width(n.length*wn); 153 np.stop().animate({scrollLeft:0},100); 154 } 155 if(opts.nav_direction=="v"){ 156 ns.height(n.length*hn); 157 np.stop().animate({scrollTop:0},100); 158 } 159 } 160 n.eq(0).addClass("now"); 161 if(opts.cycle!==1){$(opts.prev).css("opacity","0.3");} 162 163 //åå§ååå ç´ å°ºå¯¸ 164 function setWH(){ 165 if(opts.direction=="h"){ 166 setH(); 167 s.width(100000); 168 s.height("100%"); 169 f.stop().animate({scrollLeft:0},100); 170 } 171 if(opts.direction=="v"){ 172 setV(); 173 s.height(100000); 174 f.stop().animate({scrollTop:0},100); 175 } 176 } 177 setWH(); 178 179 //å°ºå¯¸è®¾ç½®å½æ° 180 function setH(){ 181 f.css("width",""); 182 c.css("width",""); 183 cm=parseInt(c.last().css("margin-left"))+parseInt(c.last().css("margin-right")); 184 if(cm==0){ 185 w = Math.floor(f.width()/getMinsize()); 186 if(opts.isfocus!=1){ 187 f.width(w*getMinsize()); 188 } 189 else{ 190 f.width("auto"); 191 } 192 c.width(w); 193 } 194 else{ 195 //if(opts.isfocus!=1){ 196 w=Math.floor((f.width()+cm)/4); 197 c.width(w-cm); 198 f.width(w*getMinsize()-cm); 199 //} 200 } 201 ww=c.length*w; 202 } 203 function setV(){ 204 f.height("auto"); 205 c.css("height",""); 206 cm=parseInt(c.css("margin-top"))+parseInt(c.css("margin-bottom")); 207 if(cm==0){ 208 h = Math.floor(f.height()/getMinsize()); 209 if(opts.isfocus!=1){ 210 f.height(h*getMinsize()); 211 } 212 else{ 213 f.height("auto"); 214 } 215 c.height(h); 216 } 217 else{ 218 if(opts.isfocus!=1){ 219 h=c.height()+cm; 220 f.height(h*getMinsize()-cm); 221 } 222 } 223 hh=c.length*h; 224 } 225 226 //设置title 227 $(opts.count).text(size); 228 $(opts.title).text(c.eq(0).attr("title")); 229 $(opts.index).text(1); 230 231 //ç¦ç¹å¾èªéåº 232 $(window).resize(function(){ 233 if(f.is(":visible")){rs();} 234 }); 235 rs(); 236 237 //èªéåº 238 function rs(){ 239 sw==0; 240 clearTimeout(ti); 241 if(getMinsize()!=0){ 242 if(opts.direction=="h"){ 243 setH(); 244 f.stop().scrollLeft(idx*w); 245 } 246 if(opts.direction=="v"){ 247 setV(); 248 f.stop().scrollTop(idx*h); 249 } 250 ti=setTimeout(function(){ 251 sw=1; 252 },500); 253 //æ¢å¤è½®æ 254 if(opts.direction=="h"){ 255 if(s.width()!==100000){ 256 setWH(); 257 } 258 } 259 if(opts.direction=="v"){ 260 if(s.height()!==100000){ 261 setWH(); 262 } 263 } 264 if(size<=getMinsize()){ 265 s.css({margin:"auto",width:w*size}); 266 $(opts.prev).hide(); 267 $(opts.next).hide(); 268 } 269 else{ 270 if(opts.direction=="h"){ 271 s.removeAttr("style").width(100000); 272 } 273 if(opts.direction=="v"){ 274 s.removeAttr("style").height(100000); 275 } 276 $(opts.prev).show(); 277 $(opts.next).show(); 278 } 279 } 280 else{ 281 //è§£é¤è½®æ 282 f.removeAttr("style"); 283 s.removeAttr("style"); 284 } 285 286 } 287 288 //夿cæ°éæ¯å¦æ»¡è¶³å¼å§æ¡ä»¶ 289 if(size>getMinsize()){ 290 291 //èªå¨å¼å§ 292 if(opts.auto==1){ 293 run(); 294 } 295 296 function run(){ 297 var t=opts.delay; 298 if(idx==0){ 299 //t=tt; 300 } 301 clearTimeout(iv); 302 iv=setTimeout(function(){ 303 move(opts.dtype); 304 run(); 305 },t); 306 } 307 308 //æ§è¡åè°å½æ° 309 if(typeof(opts.callback)=="function"){ 310 opts.callback(idx); 311 } 312 313 //-------------start-------------// 314 //æ»å¨å½æ° 315 function move(act,speed){ 316 if(!speed){speed=opts.speed;} 317 if(sw==1){ 318 sw=0; 319 if(act=="left"){ 320 if(opts.cycle!=1){ 321 if(idx+getMinsize()<size){ 322 idx++;ids++; 323 if(opts.direction=="h"){ 324 f.animate({scrollLeft:ids*w},speed,opts.easing,function(){sw=1;}); 325 } 326 if(opts.direction=="v"){ 327 f.animate({scrollTop:ids*h},speed,opts.easing,function(){sw=1;}); 328 } 329 $(opts.prev).css("opacity","1"); 330 if(idx+getMinsize()==size){ 331 $(opts.next).css("opacity","0.3"); 332 } 333 } 334 else{ 335 sw=1; 336 } 337 } 338 if(opts.cycle==1){ 339 if(idx==size-1){idx=0;} 340 else{idx++;} 341 ids++; 342 if(opts.direction=="h"){ 343 f.animate({scrollLeft:ids*w},speed,opts.easing,function(){ 344 if(f.scrollLeft()>=ww*0.5){f.scrollLeft(0);ids=0;} 345 sw=1; 346 });
347 } 348 if(opts.direction=="v"){ 349 f.animate({scrollTop:ids*h},speed,opts.easing,function(){ 350 if(f.scrollTop()>=hh*0.5){f.scrollTop(0);ids=0;} 351 sw=1; 352 }); 353 } 354 355 } 356 } 357 if(act=="right"){ 358 if(opts.cycle!=1){ 359 if(idx>0){ 360 idx--;ids--; 361 if(opts.direction=="h"){ 362 f.animate({scrollLeft:ids*w},speed,opts.easing,function(){sw=1;}); 363 } 364 if(opts.direction=="v"){ 365 f.animate({scrollTop:ids*h},speed,opts.easing,function(){sw=1;}); 366 } 367 $(opts.next).css("opacity","1"); 368 if(idx==0){ 369 $(opts.prev).css("opacity","0.3"); 370 } 371 } 372 else{ 373 sw=1; 374 } 375 } 376 if(opts.cycle==1){ 377 if(idx==0){idx=size-1;ids=size;} 378 else{idx--;} 379 ids--; 380 if(opts.direction=="h"){ 381 if(f.scrollLeft()<=0){f.scrollLeft(ww*0.5);} 382 f.animate({scrollLeft:ids*w},speed,opts.easing,function(){sw=1;}); 383 } 384 if(opts.direction=="v"){ 385 if(f.scrollTop()<=0){f.scrollTop(hh*0.5);} 386 f.animate({scrollTop:ids*h},speed,opts.easing,function(){sw=1;}); 387 } 388 } 389 } 390 n.removeClass("now"); 391 n.eq(idx).addClass("now"); 392 $(opts.title).text(c.eq(idx).attr("title")); 393 $(opts.index).text(idx+1); 394 if(opts.scrollnav){autonav();} 395 if(typeof(opts.callback)=="function"){ 396 opts.callback(idx);//æ§è¡èªå®ä¹å¨ç» 397 } 398 } 399 } 400 //å·¦å³æé® 401 if(opts.prev){ 402 $(opts.prev).hover(function(){sw=1;}); 403 $(opts.prev).unbind("click"); 404 $(opts.prev).click(function(){ 405 if(opts.arrow==1){move("right");} 406 else{move("left");} 407 if(opts.auto){ 408 //clearInterval(iv); 409 //iv = window.setInterval(function(){move(opts.dtype);},opts.delay); 410 run(); 411 } 412 if(idx1>0){idx1--;c.eq(idx1).click();} 413 414 }); 415 416 } 417 if(opts.next){ 418 $(opts.next).hover(function(){sw=1;}); 419 $(opts.next).unbind("click"); 420 $(opts.next).click(function(){ 421 if(opts.arrow==1){move("left");} 422 else{move("right");} 423 if(opts.auto){ 424 //clearInterval(iv); 425 //iv = window.setInterval(function(){move(opts.dtype);},opts.delay); 426 run(); 427 } 428 if(idx1<size-1){idx1++;c.eq(idx1).click();} 429 430 }); 431 } 432 c.click(function(){ 433 idx1=$(this).index(); 434 }); 435 436 //å¯¼èªæº¢åºé¨åæ»å¨æ¾ç¤º 437 function autonav(){ 438 if(opts.nav_direction=="h"){ 439 if(np.width()==wn){ 440 np.stop().animate({scrollLeft:wn*idx},opts.navspeed); 441 } 442 else{ 443 if(idx*wn==np.scrollLeft()){ 444 np.stop().animate({scrollLeft:np.scrollLeft()-wn},opts.navspeed); 445 } 446 if((idx+1)*wn==np.scrollLeft()+np.width()){ 447 np.stop().animate({scrollLeft:np.scrollLeft()+wn},opts.navspeed); 448 } 449 if(idx==0){np.stop().animate({scrollLeft:0},opts.navspeed);} 450 if(idx==size-1){np.stop().animate({scrollLeft:size*wn},opts.navspeed);} 451 if(np.width()%wn!=0){console.log('宽度设置é误');} 452 } 453 } 454 if(opts.nav_direction=="v"){ 455 if(idx*hn==np.scrollTop()){ 456 np.stop().animate({scrollTop:np.scrollTop()-hn},opts.navspeed); 457 } 458 if((idx+1)*hn==np.scrollTop()+np.height()){ 459 np.stop().animate({scrollTop:np.scrollTop()+hn},opts.navspeed); 460 } 461 if(idx==0){np.stop().animate({scrollTop:0},opts.navspeed);} 462 if(idx==size-1){np.stop().animate({scrollTop:size*hn},opts.navspeed);} 463 } 464 } 465 //导èªç¹å» 466 n.each(function(index, element) { 467 $(this).bind(opts.event,function(){ 468 if(opts.direction=="h"){f.stop().animate({scrollLeft:index*w},opts.speed,opts.easing,function(){sw=1;});} 469 if(opts.direction=="v"){f.stop().animate({scrollTop:index*h},opts.speed,opts.easing,function(){sw=1;});} 470 idx=index; 471 ids=index; 472 $(opts.prev).css("opacity","1"); 473 $(opts.next).css("opacity","1"); 474 if(idx+getMinsize()==size){ 475 $(opts.next).css("opacity","0.3"); 476 } 477 if(idx==0){ 478 $(opts.prev).css("opacity","0.3"); 479 } 480 n.removeClass("now"); 481 n.eq(idx).addClass("now"); 482 if(opts.scrollnav){autonav();} 483 $(opts.title).text(c.eq(idx).attr("alt")); 484 //æ§è¡åè°å½æ° 485 if(typeof(opts.callback)=="function"){ 486 opts.callback(idx); 487 } 488 if(opts.auto){ 489 //clearInterval(iv); 490 //iv = window.setInterval(function(){move(opts.dtype);},opts.delay); 491 run(); 492 } 493 }); 494 }); 495 //é¼ æ æ»è½® 496 if(opts.mousewheel){ 497 f.mousewheel(function(event,delta,deltaX,deltaY){ 498 if(delta<0){ 499 if(opts.arrow==1){move("left");} 500 else{move("right");} 501 } 502 else{ 503 if(opts.arrow==1){move("right");} 504 else{move("left");} 505 } 506 event.stopPropagation(); 507 event.preventDefault(); 508 }); 509 } 510 //é¼ æ åå ¥åæ¢ 511 if(opts.mousestop && !opts.mousewheel){ 512 f.hover(function(){sw=0},function(){sw=1}); 513 } 514 515 //è§¦æ¸æ§å¶ 516 if(opts.touch && document.addEventListener){ 517 f.attr("id","frame"+f.offset().top); 518 var touch,p0,fl,m; 519 var obj1=document.getElementById(f.attr("id")); 520 var start,end=""; 521 522 obj1.addEventListener('touchstart',function(event){ 523 if(sw==1){ 524 sw1=1; 525 touch = event.targetTouches[0]; 526 if(opts.direction=="h"){ 527 p0=touch.screenX; 528 start=touch.screenX; 529 fl=f.scrollLeft(); 530 m=w; 531 } 532 if(opts.direction=="v"){ 533 p0=touch.screenY; 534 start=touch.screenY; 535 fl=f.scrollTop(); 536 m=h; 537 } 538 if(opts.auto){ 539 clearInterval(iv); 540 } 541 } 542 },false); 543 obj1.addEventListener('touchmove',function(event){ 544 if(sw==1 && sw1==1){ 545 touch = event.targetTouches[0]; 546 if(opts.direction=="h"){ 547 f.scrollLeft(fl-(touch.screenX-p0)); 548 end=touch.screenX; 549 if(Math.abs(touch.screenX-p0)>$(window).width()*0.05){ 550 event.preventDefault();//黿¢æµè§å¨é»è®¤äºä»¶ 551 } 552 } 553 if(opts.direction=="v"){ 554 f.scrollTop(fl-(touch.screenY-p0)); 555 end=touch.screenY; 556 if(Math.abs(touch.screenY-p0)>f.height()*0.05){ 557 558 } 559 event.preventDefault();//黿¢æµè§å¨é»è®¤äºä»¶ 560 } 561 } 562 },false); 563 obj1.addEventListener('touchend',function(event){ 564 if(sw==1 && end!=""){ 565 if(end-start<m*-0.1){ 566 move("left",(m-Math.abs(end-start))/m*opts.speed); 567 } 568 else if(end-start>m*0.1){
569 move("right",(m-Math.abs(end-start))/m*opts.speed); 570 } 571 else{ 572 sw=0; 573 if(opts.direction=="h"){ 574 f.stop().animate({scrollLeft:ids*m},opts.speed*0.5,opts.easing,function(){sw=1;}); 575 } 576 else{ 577 f.stop().animate({scrollTop:ids*m},opts.speed*0.5,opts.easing,function(){sw=1;}); 578 } 579 580 } 581 if(opts.auto){ 582 //clearInterval(iv); 583 //iv = window.setInterval(function(){move(opts.dtype);},opts.delay); 584 run(); 585 } 586 sw1=0; 587 end=""; 588 } 589 },false); 590 } 591 592 //-------------end-------------// 593 } 594 }) 595 }; 596 $.fn.mScroll.defaults = { 597 auto : 1, //èªå¨å¼å§ 598 direction : "h", //æ»å¨æ¹å,h横å,v纵å 599 dtype : "left", //æ£åæ¹å 600 isfocus : 0, //æ¯å¦ä½ä¸ºç¦ç¹å¾ 601 minsize : 1, //æå°æ°é 602 speed : 500, //æ»å¨é度 603 easing : "", //ç¼å²ç±»å 604 delay : 5000, //èªå¨æ»å¨é´é 605 nav : null, //å¯¼èªæé® 606 event : "click", //导èªäºä»¶ 607 scrollnav : 0, //å¯¼èªæ»å¨ 608 navspeed : 500, //å¯¼èªæ»å¨é度 609 nav_direction : "h", //å¯¼èªæ¹å,h横å,v纵å 610 prev : null, //åä¸ä¸ª 611 next : null, //åä¸ä¸ª 612 index : null, //å½ååºå· 613 count : null, //æ»æ° 614 title : null, //æ é¢ 615 arrow : 1, //æ¯å¦å转 616 cycle : 1, //æ¯å¦å¾ªç¯ 617 mousestop : 1, //é¼ æ åå ¥åæ¢ 618 mousewheel : 0, //å¼å¯æ»è½®äºä»¶ 619 touch : 0, //å¼å¯è§¦æ¸äºä»¶ 620 callback : function(idx){} //åæå½æ° 621 } 622})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.