1function LrScroll2($box, config) { 2 this.opts = $.extend(true, { 3 touchTarget: null, //#focus 4 onlyOne: false, 5 hasResize: false, 6 oneSize: 0, 7 sNum: 2, //æ»å¨åä½ä¸ªæ° 8 spacing: 0, //åä½é´è· 9 rowNum: 1, //ä¸å䏿å 个 10 auto: false, //false|æ»å¨é´éæ¶é´ å¦ï¼3000 11 numberNav: false, 12 fullScreen: false, 13 anTime: 400, 14 scrollType: "hor", // hor ver fade 15 curItemClass:"lr-scroll-cur", 16 $prev:"", 17 $next:"", 18 navNumShow: true, 19 makeNav: function () { 20 //çææ°å导èªï¼å¯ä»¥èªå®ä¹ï¼æ¯å¦å¯ä»¥èªå®ä¹çæç¼©ç¥å¾å¯¼èª 注æï¼ä¸ç®¡ç»æ/æ ç¾æä¹åï¼s-nav-link ç±»åä¸å®è¦ä¿ç å¦ï¼<li class="s-nav-link"></li> 21 var self = this; 22 var i = 0, temp = []; 23 for (i; i < self.pages; i++) { 24 self.opts.navNumShow ? temp.push('<a class="s-nav-link">' + (i + 1) + '</a>') : temp.push('<a class="s-nav-link"></a>'); 25 } 26 self.$scrollNav.html(temp.join("")); 27 }, 28 onInit: function () { 29 }, 30 animationEnd: function () { 31 } 32 }, config); 33 this.$win = $(window); 34 this.$box = $box; 35 this.$prev = this.opts.$prev||this.$box.find(".prev"); 36 this.$next = this.opts.$next||this.$box.find(".next"); 37 this.$scrollNav = this.$box.find(".scrollnav"); 38 this.$scrollCon = this.$box.find(".scrollcon"); 39 this.$scrollList = this.$box.find(".scrolllist"); 40 this.$lis = this.$scrollList.children("li"); 41 this.liLen = this.opts.oneSize ? Math.ceil(this.$scrollList.width() / this.opts.oneSize) : this.$lis.length; 42 this.pages = this.opts.oneSize ? Math.ceil(this.$scrollList.width() / this.opts.oneSize * this.opts.sNum) : Math.ceil(this.liLen / this.opts.sNum); 43 this.pageIndex = 0; 44 this.scrolling = 0; 45 this.pause = 0; 46 this.size = { 47 scrollListW: 0, 48 scrollListH: 0, 49 scrollSize: 0, 50 scrollSizeCur: 0 51 }; 52 this.init(); 53 } 54 55LrScroll2.prototype = { 56 init: function () { 57 var This = this; 58 this.setSize(); 59 this.bindEvent(); 60 this.opts.makeNav.call(this); 61 62 this.$box.addClass('scroll-' + this.opts.scrollType); 63 this.scrollNavLinks = this.$scrollNav.find(".s-nav-link"); 64 this.scrollNavLinks.eq(0).trigger("click"); 65 this.$lis.css({"margin-right": this.opts.spacing}); 66 67 this.opts.scrollType=="fade" && this.zIndex(); 68 69 //èªå¨æ»å¨ 70 if (this.opts.auto && typeof this.opts.auto == "number") { 71 (function () { 72 clearTimeout(this.timer); 73 !This.pause && This.$next.trigger("click"); 74 This.timer = setTimeout(arguments.callee, This.opts.auto) 75 })(); 76 } 77 this.opts.onInit.call(this); 78 }, 79 zIndex:function(){ 80 /*var zIndex = this.liLen; 81 this.$scrollList.children("li").each(function(i){ 82 $(this).css({"z-index":zIndex}); 83 zIndex--; 84 });*/ 85 }, 86 setSize: function () { 87 var $first = this.$lis.eq(0), 88 $firstW = !this.opts.oneSize ? $first.width() : this.opts.oneSize, 89 opts = this.opts; 90 if (this.opts.fullScreen) { 91 $firstW = this.$win.width(); 92 this.$lis.css({"width": $firstW}); 93 } 94 if (this.opts.onlyOne) {
95 $firstW = this.$scrollCon.width(); 96 this.$lis.css({"width": $firstW}); 97 } 98 if (this.opts.oneSize || this.opts.onlyOne) { 99 this.size.scrollListW = (opts.scrollType == "hor") ? ($firstW + opts.spacing) * this.liLen : this.$scrollCon.width(); 100 this.size.scrollSize = (opts.scrollType == "hor") ? ($firstW + opts.spacing) * opts.sNum : this.$scrollCon.height(); 101 } else { 102 this.size.scrollListW = (opts.scrollType == "hor") ? ($firstW + opts.spacing) * this.liLen : this.$scrollCon.width(); 103 this.size.scrollSize = (opts.scrollType == "hor") ? ($firstW + opts.spacing) * opts.sNum : this.$scrollCon.height(); 104 } 105 this.$scrollList.css({"width": this.size.scrollListW + opts.spacing}); 106 }, 107 bindEvent: function () { 108 var This = this; 109 this.$box.off().hover( 110 function () { 111 This.pause = 1; 112 }, 113 function () { 114 This.pause = 0; 115 } 116 ); 117 this.$prev.off().on("click", function () { 118 if (This.scrolling || This.pageIndex < 0) { 119 return 120 } 121 if (This.pageIndex == 0) This.pageIndex = This.pages; 122 This.scrolling = 1; 123 This.pageIndex--; 124 This.animation(-This.size.scrollSize * This.pageIndex); 125 }); 126 this.$next.off().on("click", function () { 127 if (This.scrolling) { 128 return 129 } 130 This.scrolling = 1; 131 This.pageIndex++; 132 if (This.pageIndex == This.pages) This.pageIndex = 0; 133 This.animation(-This.size.scrollSize * This.pageIndex); 134 }); 135 this.$scrollNav.off().on("click", ".s-nav-link", function () { 136 var $this = $(this),index; 137 if($this.hasClass("cur")){ 138 return 139 } 140 141 index = $this.index(); 142 $this.addClass("cur").siblings().removeClass("cur"); 143 144 This.scrolling = 1; 145 This.pageIndex = index; 146 if(This.opts.scrollType == "fade"){ 147 //æ·¡å ¥æ·¡åº 148 This.animationFade("a"); 149 }else{ 150 This.animation(-This.size.scrollSize * This.pageIndex); 151 } 152 }); 153 if (this.opts.fullScreen || this.opts.hasResize) { 154 var timer = 0, index = 0; 155 this.$win.off("resize.scroll").on("resize.scroll", function () { 156 clearTimeout(timer); 157 timer = setTimeout(function () { 158 This.setSize(); 159 //å ¨å±çè¯çªå£æ¹åè¦éç½®leftå¼ 160 if(This.opts.scrollType=="hor"){ 161 This.$scrollList.css("left", -This.size.scrollSize * This.pageIndex); 162 } 163 clearTimeout(timer); 164 }, 100); 165 }) 166 } 167 168 if (This.opts.touchTarget && typeof touch == "object") { 169 touch.on("#" + This.opts.touchTarget, 'touchstart', function (ev) { 170 ev.preventDefault(); 171 }); 172 173 var target = document.getElementById(This.opts.touchTarget); 174 touch.on(target, 'swiperight', function (ev) { 175 //log("å峿»å¨."); 176 This.$prev.trigger("click"); 177 }); 178 179 touch.on(target, 'swipeleft', function (ev) { 180 //log("åå·¦æ»å¨."); 181 This.$next.trigger("click"); 182 }); 183 } 184 185 }, 186 animation: function (size) { 187 188 this.$scrollNav.find("a").eq(this.pageIndex).addClass("cur").siblings().removeClass("cur"); 189 190 if(this.opts.onlyOne||this.opts.scrollType == "fade"){ 191 //this.$scrollList.children("li").eq(0).addClass(this.opts.curItemClass); 192 //this.$lis.eq(this.pageIndex).addClass(this.opts.curItemClass).siblings().removeClass(this.opts.curItemClass); 193 } 194 195 if(this.opts.scrollType == "fade"){ 196 //æ·¡å ¥æ·¡åº 197 this.animationFade() 198 }else{ 199 this.animationLeftTop(size); 200 } 201 }, 202 animationFade:function(clickTarget){ 203 var This = this; 204 var nextIndex = This.pageIndex; 205 206 this.$scrollList.children("li").eq(nextIndex) 207 .animate({"opacity":1}, 800) 208 .siblings("li").animate({"opacity":0}, 800, function () { 209 This.scrolling = 0; 210 setTimeout(function(){ 211 This.$scrollList.children("li").eq(nextIndex).addClass(This.opts.curItemClass).siblings().removeClass(This.opts.curItemClass); 212 },100); 213 214 This.opts.animationEnd.call(This); 215 }); 216 }, 217 animationLeftTop:function(size){ 218 var This = this, 219 anObj = this.opts.scrollType == "hor" ? {left: size} : {top: size}; 220 221 this.scrollSizeCur = size; 222 223 this.$scrollList.animate(anObj, 400, function () { 224 This.scrolling = 0; 225 This.opts.animationEnd.call(This); 226 }) 227 } 228 229 }; 230 231
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.