1/** 2 * @name jQuery.touchSlider 3 * @author dohoons ( http://dohoons.com/ ) 4 * 5 * @version 1.1.1 6 * @since 201106 7 * 8 * @param Object settings íê²½ë³ì ì¤ë¸ì í¸ 9 * roll - ìí (default true) 10 * flexible - ì ë ë ì´ìì (default true) 11 * resize - 리ì¬ì´ì¦ ì¬ì© (default false) 12 * view - ë¤ì¤ ì»¬ë¼ (default 1) 13 * speed - ì ëë©ì´ì ìë (default 75) 14 * range - ëê¹ íì ë²ì (default 0.15) 15 * page - ì´ê¸° íì´ì§ (default 1) 16 * transition - CSS3 transition ì¬ì© (default true) 17 * btn_prev - prev ë²í¼ (jQuery Object, default null) 18 * btn_next - next ë²í¼ (jQuery Object, default null) 19 * paging - page ë²í¼ (jQuery Object, default null) 20 * sidePage - ì¬ì´ë íì´ì§ ì¬ì© (default false) 21 * initComplete - ì´ê¸°í ì½ë°± 22 * counter - ì¬ë¼ì´ë ì½ë°±, ì¹´ì´í° 23 * autoplay - ìëìì§ì ê´ë ¨ ìµì (Object) 24 * 25 * @example 26 27 $("#target").touchSlider({ 28 page : 2 29 }); 30 31*/ 32 33(function ($) { 34 35 $.fn.touchSlider = function (settings) { 36 37 $.fn.touchSlider.defaults = { 38 roll : true, 39 flexible : true, 40 resize : false, 41 btn_prev : null, 42 btn_next : null, 43 paging : null, 44 speed : 150, 45 view : 1, 46 range : 0.15, 47 page : 1, 48 sidePage : false, 49 transition : true, 50 initComplete : null, 51 counter : null, 52 propagation : false, 53 autoplay : { 54 enable : false, 55 pauseHover : true, 56 addHoverTarget : "", 57 interval : 3500 58 }, 59 supportsCssTransitions : (function (style) { 60 var prefixes = ['Webkit','Moz','Ms']; 61 for(var i=0, l=prefixes.length; i < l; i++ ) { 62 if( typeof style[prefixes[i] + 'Transition'] !== 'undefined') { 63 return true; 64 } 65 } 66 return false; 67 })(document.createElement('div').style) 68 }; 69 70 var opts = $.extend(true, {}, $.fn.touchSlider.defaults, settings); 71 72 return this.each(function () { 73 74 var _this = this; 75 76 $.fn.extend(this, touchSlider); 77 this.opts = opts; 78 this.init(); 79 80 $(window).on("orientationchange resize", function () { 81 _this.resize(_this); 82 }); 83 }); 84 85 }; 86 87 var touchSlider = { 88 89 init : function () { 90 var _this = this; 91 92 this._view = this.opts.view; 93 this._speed = this.opts.speed; 94 this._tg = $(this); 95 this._list = this._tg.children().children(); 96 this._width = parseInt(this._tg.css("width")); 97 this._item_w = parseInt(this._list.css("width")); 98 this._len = this._list.length; 99 this._range = this.opts.range * this._width; 100 this._pos = []; 101 this._start = []; 102 this._startX = 0; 103 this._startY = 0; 104 this._left = 0; 105 this._top = 0; 106 this._drag = false; 107 this._link = true; 108 this._scroll = false; 109 this._btn_prev; 110 this._btn_next; 111 this._timer; 112 this._hover_tg = []; 113 114 this._tg 115 .off("touchstart", this.touchstart) 116 .off("touchmove", this.touchmove) 117 .off("touchend", this.touchend) 118 .off("touchcancel", this.touchend) 119 .off("dragstart", this.touchstart) 120 .off("drag", this.touchmove) 121 .off("dragend", this.touchend) 122 .on("touchstart", this.touchstart) 123 .on("touchmove", this.touchmove) 124 .on("touchend", this.touchend) 125 .on("touchcancel", this.touchend) 126 .on("dragstart", this.touchstart) 127 .on("drag", this.touchmove) 128 .on("dragend", this.touchend); 129 130 this._tg.children().css({ 131 "width":this._width + "px", 132 "overflow":"visible" 133 }); 134 135 if(this.opts.flexible) this._item_w = this._width / this._view; 136 137 if(this.opts.roll) { 138 if(this._len % this._view > 0) { 139 var blank = $(document.createElement(this._list.eq(0).prop("tagName"))).hide(); 140 var cnt = this._view - (this._len % this._view); 141 for(var i=0; i<cnt; ++i) { 142 this._list.parent().append(blank.clone()); 143 } 144 } 145 this._list = this._tg.children().children(); 146 this._len = this._list.length; 147 this._len = (this._len / this._view) * this._view; 148 } 149 150 var page_gap = (this.opts.page > 1 && this.opts.page <= this._len) ? (this.opts.page - 1) * this._item_w * this._view : 0; 151 152 for(var i=0, len=this._len; i<len; ++i) { 153 this._pos[i] = this._item_w * i - page_gap; 154 this._start[i] = this._pos[i]; 155 this._list.eq(i).css({ 156 "float" : "none", 157 "position" : "absolute", 158 "top" : "0", 159 "width" : this._item_w + "px" 160 }); 161 162 this.move({ 163 tg : this._list.eq(i), 164 speed : 0, 165 to : this._pos[i] 166 }); 167 } 168 169 if(this.opts.btn_prev && this.opts.btn_next) { 170 this.opts.btn_prev.off("click").on("click", function() { 171 _this.animate(1, true); 172 return false;
173 }) 174 this.opts.btn_next.off("click").on("click", function() { 175 _this.animate(-1, true); 176 return false; 177 }); 178 } 179 180 if(this.opts.paging) { 181 $(this._list).each(function (i, el) { 182 var btn_page = _this.opts.paging.eq(0).clone(); 183 _this.opts.paging.before(btn_page); 184 185 btn_page.off("click").on("click", function(e) { 186 _this.go_page(i, e); 187 return false; 188 }); 189 }); 190 191 this.opts.paging.remove(); 192 } 193 194 if(this.opts.autoplay.enable) { 195 this._hover_tg = []; 196 this._hover_tg.push(this._tg); 197 198 if(this.opts.btn_prev && this.opts.btn_next) { 199 this._hover_tg.push(this.opts.btn_prev); 200 this._hover_tg.push(this.opts.btn_next); 201 } 202 203 if(this.opts.autoplay.addHoverTarget != "") { 204 this._hover_tg.push($(this.opts.autoplay.addHoverTarget)); 205 } 206 207 if(this.opts.autoplay.pauseHover) { 208 $(this._hover_tg).each(function(i, el) { 209 $(this).off("mouseenter mouseleave").on("mouseenter mouseleave", function (e) { 210 if(e.type == "mouseenter") { 211 _this.autoStop(); 212 } else { 213 _this.autoPlay(); 214 } 215 }); 216 }); 217 } 218 219 this.autoStop(); 220 this.autoPlay(); 221 } 222 223 this._tg.find("a").off("click").on("click", function (e) { 224 if(!_this._link) { 225 return false; 226 } 227 }); 228 229 this.initComplete(); 230 this.counter(); 231 }, 232 233 initComplete : function () { 234 if(this.opts.sidePage) { 235 this.animate(-1, true, 0); 236 this.animate(1, true, 0); 237 } 238 if(typeof(this.opts.initComplete) == "function") { 239 this.opts.initComplete.call(this,this); 240 } 241 }, 242 243 resize : function (e) { 244 if(e.opts.flexible) { 245 var tmp_w = e._item_w; 246 247 e._width = parseInt(e._tg.css("width")); 248 e._item_w = e._width / e._view; 249 e._range = e.opts.range * e._width; 250 251 for(var i=0, len=e._len; i<len; ++i) { 252 e._pos[i] = e._pos[i] / tmp_w * e._item_w; 253 e._start[i] = e._start[i] / tmp_w * e._item_w; 254 e._list.eq(i).css({ 255 "width" : e._item_w + "px" 256 }); 257 258 this.move({ 259 tg : e._list.eq(i), 260 speed : 0, 261 to : e._pos[i] 262 }); 263 } 264 } 265 266 this.counter(); 267 }, 268 269 touchstart : function (e) { 270 if(!this.opts.propagation) { 271 e.stopPropagation(); 272 } 273 if((e.type == "touchstart" && e.originalEvent.touches.length <= 1) || e.type == "dragstart") { 274 this._startX = e.pageX || e.originalEvent.touches[0].pageX; 275 this._startY = e.pageY || e.originalEvent.touches[0].pageY; 276 this._scroll = false; 277 this._start = this._pos.slice(0); 278 } 279 }, 280 281 touchmove : function (e) { 282 if(!this.opts.propagation) { 283 e.stopPropagation(); 284 } 285 if((e.type == "touchmove" && e.originalEvent.touches.length <= 1) || e.type == "drag") { 286 this._left = (e.pageX || e.originalEvent.touches[0].pageX) - this._startX; 287 this._top = (e.pageY || e.originalEvent.touches[0].pageY) - this._startY; 288 var w = this._left < 0 ? this._left * -1 : this._left; 289 var h = this._top < 0 ? this._top * -1 : this._top; 290 291 if (w < h || this._scroll) { 292 this._left = 0; 293 this._drag = false; 294 this._link = true; 295 this._scroll = true; 296 } else { 297 e.preventDefault(); 298 this._drag = true; 299 this._link = false; 300 this._scroll = false; 301 this.position(e); 302 } 303 304 for(var i=0, len=this._len; i<len; ++i) { 305 var tmp = this._start[i] + this._left; 306 307 this.move({ 308 tg : this._list.eq(i), 309 speed : 0, 310 to : tmp 311 }); 312 313 this._pos[i] = tmp; 314 } 315 } 316 }, 317 318 touchend : function (e) { 319 if(!this.opts.propagation) { 320 e.stopPropagation(); 321 } 322 if(this._scroll) { 323 this._drag = false; 324 this._link = true; 325 this._scroll = false; 326 } else { 327 this.animate(this.direction()); 328 this._drag = false; 329 this._scroll = true; 330 331 var _this = this; 332 setTimeout(function () { 333 _this._link = true; 334 },50); 335 } 336 }, 337 338 position : function (d) { 339 var len = this._len, 340 view = this._view, 341 gap = view * this._item_w; 342 343 if(d == -1 || d == 1) { 344 this._startX = 0; 345 this._start = this._pos.slice(0); 346 this._left = d * gap; 347 } else { 348 if(this._left > gap) this._left = gap;
349 if(this._left < - gap) this._left = - gap; 350 } 351 352 if(this.opts.roll) { 353 var tmp_pos = this._pos.slice(0).sort(function(a,b){return a-b;}), 354 max_chk = tmp_pos[len-view], 355 p_min = $.inArray(tmp_pos[0], this._pos), 356 p_max = $.inArray(max_chk, this._pos), 357 p = (this.opts.sidePage) ? 3 : 1; 358 359 if(view <= 1) max_chk = len - p; 360 361 if((d == 1 && tmp_pos[p-1] >= 0) || (this._drag && tmp_pos[p-1] > 0)) { 362 for(var i=0; i<view; ++i, ++p_min, ++p_max) { 363 this._start[p_max] = this._start[p_min] - gap; 364 this.move({ 365 tg : this._list.eq(p_max), 366 speed : 0, 367 to : this._start[p_max] 368 }); 369 } 370 } else if((d == -1 && tmp_pos[max_chk] <= 0) || (this._drag && tmp_pos[max_chk] <= 0)) { 371 for(var i=0; i<view; ++i, ++p_min, ++p_max) { 372 this._start[p_min] = this._start[p_max] + gap; 373 this.move({ 374 tg : this._list.eq(p_min), 375 speed : 0, 376 to : this._start[p_min] 377 }); 378 } 379 } 380 } else { 381 if(this.limit_chk()) this._left = this._left / 2; 382 } 383 }, 384 385 move : function (obj) { 386 var transition = obj.speed + "ms", 387 transform = "translate3d(" + obj.to + "px,0,0)"; 388 if(this.opts.supportsCssTransitions && this.opts.transition) { 389 obj.tg.css({ 390 "left" : "0", 391 "-moz-transition" : transition, 392 "-moz-transform" : transform, 393 "-ms-transition" : transition, 394 "-ms-transform" : transform, 395 "-webkit-transition" : transition, 396 "-webkit-transform" : transform, 397 "transition" : transition, 398 "transform" : transform 399 }); 400 } else { 401 obj.tg.css("left", obj.to + "px"); 402 } 403 }, 404 405 animate : function (d, btn_click, speed) { 406 if(this._drag || !this._scroll || btn_click) { 407 var speed = (speed > -1) ? speed : this._speed, 408 gap = d * (this._item_w * this._view), 409 list = this._list, 410 len = this._len, 411 transition = speed + "ms ease", 412 transform = ""; 413 414 if(btn_click) this.position(d); 415 416 if(this._left == 0 || (!this.opts.roll && this.limit_chk()) ) gap = 0; 417 418 for(var i=0; i<len; ++i) { 419 this._pos[i] = this._start[i] + gap; 420 421 if(this.opts.supportsCssTransitions && this.opts.transition) { 422 transform = "translate3d(" + this._pos[i] + "px,0,0)"; 423 list.eq(i).css({ 424 "left" : "0", 425 "-moz-transition" : transition, 426 "-moz-transform" : transform, 427 "-ms-transition" : transition, 428 "-ms-transform" : transform, 429 "-webkit-transition" : transition, 430 "-webkit-transform" : transform, 431 "transition" : transition, 432 "transform" : transform 433 }); 434 } else { 435 list.eq(i).stop().animate({"left": this._pos[i] + "px"}, speed); 436 } 437 } 438 439 this.counter(); 440 } 441 }, 442 443 direction : function () { 444 var r = 0; 445 446 if(this._left < -(this._range)) r = -1; 447 else if(this._left > this._range) r = 1; 448 449 if(!this._drag || this._scroll) r = 0; 450 451 return r; 452 }, 453 454 limit_chk : function () { 455 var last_p = parseInt((this._len - 1) / this._view) * this._view; 456 return ( (this._start[0] == 0 && this._left > 0) || (this._start[last_p] == 0 && this._left < 0) ); 457 }, 458 459 go_page : function (i, e) { 460 var crt = ($.inArray(0, this._pos) / this._view) + 1; 461 var cal = crt - (i + 1); 462 463 while(cal != 0) { 464 if(cal < 0) { 465 this.animate(-1, true); 466 cal++; 467 } else if(cal > 0) { 468 this.animate(1, true); 469 cal--; 470 } 471 } 472 }, 473 474 get_page : function () { 475 return { 476 obj : this, 477 total : Math.ceil(this._len / this._view), 478 current : ($.inArray(0, this._pos) / this._view) + 1 479 } 480 }, 481 482 counter : function () { 483 if($.inArray(0, this._pos) < 0) { 484 this.init(); 485 } 486 this.opts.page = this.get_page().current; 487 if(this.opts.resize) { 488 this._tg.css({ 489 "height" : this._list.eq(this.opts.page-1).height() + "px" 490 }); 491 } 492 if(typeof(this.opts.counter) == "function") { 493 this.opts.counter.call(this, this.get_page()); 494 } 495 }, 496 497 autoPlay : function () { 498 var _this = this; 499 this._timer = setInterval(function () { 500 if(_this.opts.autoplay.enable) { 501 var page = _this.get_page(); 502 if(page.current == page.total) { 503 _this.go_page(0); 504 } else { 505 _this.animate(-1, true); 506 } 507 } 508 }, this.opts.autoplay.interval); 509 }, 510 511 autoStop : function () { 512 clearInterval(this._timer); 513 }, 514 515 autoPauseToggle : function () { 516 if(this.opts.autoplay.enable) { 517 this.autoStop(); 518 this.opts.autoplay.enable = false;
519 return "stopped"; 520 } else { 521 this.opts.autoplay.enable = true; 522 this.autoPlay(); 523 return "started"; 524 } 525 } 526 527 }; 528 529})(jQuery); 530 531 532 533 534/** 535 * @name jQuery.touchFlow 536 * @author dohoons ( http://dohoons.com/ ) 537 * 538 * @version 1.5.0 539 * @since 201602 540 * 541 * @param Object settings íê²½ë³ì ì¤ë¸ì í¸ 542 * axis - ëëê·¸ ë°©í¥ (String, default "x") 543 * page - ì´ê¸° íì´ì§ (Number or String, default 0) 544 * speed - ì ëë©ì´ì ìë (Number, default 200) 545 * snap - ì¤ë ê¸°ë¥ (Boolean, default false) 546 * scrollbar - ì¤í¬ë¡¤ë° íì (Boolean, default false) 547 * scrollbarAutoHide - ì¤í¬ë¡¤ë° ìë ì¨ê¹ (Boolean, default true) 548 * initComplete - ì´ê¸°í ì½ë°± (Function, default null) 549 * stopped - ì ì§ ì½ë°± (Function, default null) 550 * resizeend - ìëì° ë¦¬ì¬ì´ì¦ ì½ë°± (Function, default null) 551 * 552 * @example 553 554 $("#target").touchFlow({ 555 page : 2 556 }); 557 558 $("#target").data("touchFlow").go_page(4); 559*/ 560 561/* global jQuery */ 562 563;(function ($) { 564 565 "use strict"; 566 567 var supportsCssTransitions = 'transition' in document.documentElement.style || 'WebkitTransition' in document.documentElement.style; 568 569 var TouchFlow = function (el, settings){ 570 571 var defaults = { 572 axis : "x", 573 page : 0, 574 speed : 200, 575 side: 0.15, 576 snap : false, 577 scrollbar : false, 578 scrollbarAutoHide : true, 579 initComplete : null, 580 stopped : null, 581 resizeend : null 582 }; 583 584 this.opts = $.extend({}, defaults, settings); 585 this.target = el; 586 this.wrap = $(el); 587 this.list = this.wrap.children(); 588 this.wrapw = null; 589 this.wraph = null; 590 this.listw = null; 591 this.listh = null; 592 this.tmp = null; 593 this.ticker = null; 594 this.duration = this.opts.speed; 595 this.side = this.opts.side; 596 this.delay = 17; 597 this.posx = 0; 598 this.posy = 0; 599 this.startx = 0; 600 this.starty = 0; 601 this.speedx = 0; 602 this.speedy = 0; 603 this.prevx = 0; 604 this.prevy = 0; 605 this.tempx = 0; 606 this.tempy = 0; 607 this.right = 0; 608 this.bottom = 0; 609 this.state = false; 610 this.link = true; 611 this.lastmove = null; 612 this.scroll = {}; 613 614 this.init(); 615 }; 616 617 TouchFlow.prototype = { 618 619 init: function () { 620 this.list = this.wrap.children(); 621 this.state = false; 622 623 if(typeof(this.opts.page) === "string") { 624 this.opts.page = $(this.target).find(this.opts.page).eq(0).index(); 625 } 626 627 this.set_limit(); 628 this.go_page(this.opts.page); 629 630 this.list 631 .off("touchstart", this, this.touchstart) 632 .off("touchmove", this, this.touchmove) 633 .off("touchend touchcancel", this.touchend) 634 .off("dragstart", this, this.touchstart) 635 .off("drag", this, this.touchmove) 636 .off("dragend", this, this.touchend) 637 .off("transitionend", this, this.transitionend) 638 .off("wheel", this, this.wheel) 639 .on("touchstart", this, this.touchstart) 640 .on("touchmove", this, this.touchmove) 641 .on("touchend touchcancel", this, this.touchend) 642 .on("dragstart", this, this.touchstart) 643 .on("drag", this, this.touchmove) 644 .on("dragend", this, this.touchend) 645 .on("transitionend", this, this.transitionend) 646 .on('wheel', this, this.wheel); 647 648 $(window).off("resize", this, this.resize).on("resize", this, this.resize); 649 650 this.list.find("a").on("click", this, function (e) { 651 if(!e.data.link) { 652 return false; 653 } 654 }); 655 656 if(this.opts.scrollbar) { 657 this.scrollbar_init(); 658 } 659 660 if(typeof(this.opts.initComplete) === "function") { 661 this.opts.initComplete.call(this, this.get_event_data()); 662 } 663 664 return this; 665 }, 666 667 scrollbar_init : function () { 668 if(this.scroll.wrap === undefined) { 669 this.scroll.wrap = $('<div class="touchflow-scrollbar"><div></div></div>'); 670 this.scroll.bar = this.scroll.wrap.find(" > div"); 671 672 this.wrap.append(this.scroll.wrap); 673 this.scrollbar_pos(); 674 } 675 }, 676 677 scrollbar_pos : function (f) { 678 if(this.opts.scrollbar) { 679 var wrap = this.scroll.wrap, 680 bar = this.scroll.bar, 681 full, 682 pos, 683 transition = (f) ? "300ms" : "0ms"; 684 685 if(this.opts.axis === "x") { 686 full = this.wrapw / this.listw * 100; 687 pos = -this.posX() / this.listw * 100; 688 689 wrap.css({ 690 width : "100%", 691 height : "5px", 692 opacity : 1 693 }); 694 695 bar.css({ 696 width : full + "%", 697 height : "5px", 698 left : pos + "%", 699 transition : transition 700 }); 701 } else if(this.opts.axis === "y") { 702 full = this.wraph / this.listh * 100; 703 pos = -this.posY() / this.listh * 100; 704 705 wrap.css({ 706 width : "5px", 707 height : "100%", 708 opacity : 1 709 }); 710 711 bar.css({ 712 width : "5px", 713 height : full + "%", 714 top : pos + "%", 715 transition : transition 716 }); 717 } 718 719 if(this.opts.scrollbarAutoHide) { 720 setTimeout(function () { 721 if(f) { 722 wrap.css({ 723 opacity : 0 724 }); 725 } 726 }, 300); 727 } 728 } 729 }, 730 731 touchstart : function (e) { 732 var obj = e.data; 733 obj.startx = e.originalEvent.touches ? e.originalEvent.touches[0].pageX : e.pageX;
734 obj.starty = e.originalEvent.touches ? e.originalEvent.touches[0].pageY : e.pageY; 735 obj.posx = obj.startx - $(this).position().left; 736 obj.posy = obj.starty - $(this).position().top; 737 738 if(typeof(obj.opts.stopped) === "function" && obj.speedx !== 0) { 739 obj.opts.stopped.call(obj, obj.get_event_data()); 740 } 741 742 obj.speedx = 0; 743 obj.speedy = 0; 744 obj.prevx = 0; 745 obj.prevy = 0; 746 obj.tempx = 0; 747 obj.tempy = 0; 748 749 obj.stop_animation(); 750 obj.start_animation(); 751 752 obj.state = true; 753 obj.lastmove = e; 754 e.stopPropagation(); 755 }, 756 757 touchmove : function (e) { 758 var obj = e.data, 759 pageX = e.originalEvent.touches ? e.originalEvent.touches[0].pageX : e.pageX, 760 pageY = e.originalEvent.touches ? e.originalEvent.touches[0].pageY : e.pageY, 761 left = pageX - obj.startx, 762 top = pageY - obj.starty, 763 w = left < 0 ? left * -1 : left, 764 h = top < 0 ? top * -1 : top, 765 thisx = pageX - obj.posx, 766 thisy = pageY - obj.posy, 767 limitx = obj.get_limit({x:thisx}), 768 limity = obj.get_limit({y:thisy}), 769 gapx = thisx - limitx, 770 gapy = thisy - limity; 771 772 if(obj.opts.axis == "x" && w > h) { 773 obj.link = false; 774 e.preventDefault(); 775 776 if(Math.abs(gapx) > 0) { 777 thisx -= gapx / 2; 778 } 779 780 obj.set_pos({x:thisx}); 781 } else if(obj.opts.axis == "y" && w < h) { 782 obj.link = false; 783 e.preventDefault(); 784 785 if(Math.abs(gapy) > 0) { 786 thisy -= gapy / 2; 787 } 788 789 obj.set_pos({y:thisy}); 790 } 791 792 obj.lastmove = e; 793 e.stopPropagation(); 794 }, 795 796 touchend : function (e) { 797 var obj = e.data, 798 pageX = obj.lastmove.originalEvent.touches ? obj.lastmove.originalEvent.touches[0].pageX : obj.lastmove.pageX, 799 pageY = obj.lastmove.originalEvent.touches ? obj.lastmove.originalEvent.touches[0].pageY : obj.lastmove.pageY, 800 left = pageX - obj.startx, 801 top = pageY - obj.starty, 802 thisx = $(this).position().left, 803 thisy = $(this).position().top, 804 to = 0; 805 806 obj.state = false; 807 obj.speedx = obj.tempx; 808 obj.speedy = obj.tempy; 809 810 if(obj.opts.axis == "x" && !obj.limit_chk({x:thisx})) { 811 if(left < 0) { 812 to = obj.right; 813 } else { 814 to = 0; 815 } 816 obj.stop_animation(); 817 obj.set_pos({x:to}, obj.duration); 818 } else if(obj.opts.axis == "y" && !obj.limit_chk({y:thisy})) { 819 if(top < 0) { 820 to = obj.bottom; 821 } else { 822 to = 0; 823 } 824 obj.stop_animation(); 825 obj.set_pos({y:to}, obj.duration); 826 } 827 828 setTimeout(function () { 829 obj.link = true; 830 },50); 831 e.stopPropagation(); 832 }, 833 834 transitionend : function (e) { 835 var obj = e.data; 836 if(typeof(obj.opts.stopped) === "function") { 837 obj.opts.stopped.call(obj, obj.get_event_data()); 838 } 839 obj.scrollbar_pos(true); 840 }, 841 842 resize : function (e) { 843 var obj = e.data; 844 845 clearTimeout(obj.tmp); 846 obj.tmp = setTimeout(function () { 847 obj.set_limit(); 848 obj.pos_control(); 849 850 if(typeof(obj.opts.resizeend) === "function") { 851 obj.opts.resizeend.call(obj, obj.get_event_data()); 852 } 853 854 obj.scrollbar_pos(true); 855 }, 200); 856 }, 857 858 wheel : function (e) { 859 var obj = e.data, 860 pos = 0, 861 chk = {}, 862 gap = 100; 863 864 if(e.originalEvent.deltaY > 0) { 865 if(obj.opts.axis === "x") { 866 pos = obj.posX(); 867 chk = {x:pos - 1}; 868 obj.posX( pos - gap ); 869 } else { 870 pos = obj.posY(); 871 chk = {y:pos - 1}; 872 obj.posY( pos - gap ); 873 } 874 } else if(e.originalEvent.deltaY < 0) { 875 if(obj.opts.axis === "x") { 876 pos = obj.posX(); 877 chk = {x:pos + 1}; 878 obj.posX( pos + gap ); 879 } else { 880 pos = obj.posY(); 881 chk = {y:pos + 1}; 882 obj.posY( pos + gap ); 883 } 884 } else { 885 return true; 886 } 887 888 if(obj.limit_chk(chk) === true) { 889 e.preventDefault(); 890 } 891 892 obj.scrollbar_pos(true); 893 }, 894 895 get_nearby_page : function (n) {
896 var pos = (typeof n === "number") ? Math.abs(n) : null, 897 arr = [], 898 list_pos = this.list.offset(), 899 li = this.list.children(), 900 len = li.length, 901 tg = ""; 902 903 if(this.opts.axis === "x") { 904 tg = "left"; 905 if(pos === null) { 906 pos = Math.abs(list_pos.left); 907 } 908 } else { 909 tg = "top"; 910 if(pos === null) { 911 pos = Math.abs(list_pos.top); 912 } 913 } 914 915 for(var i=0; i<len; ++i) { 916 arr[i] = Math.abs(li.eq(i).offset()[tg] - list_pos[tg] - pos); 917 } 918 919 return arr.indexOf(Math.min.apply(null, arr)); 920 }, 921 922 start_animation : function () { 923 if(window.requestAnimationFrame) { 924 this.ticker = requestAnimationFrame(this.move.bind(this)); 925 } else { 926 this.ticker = setTimeout(this.move.bind(this), this.delay); 927 } 928 }, 929 930 stop_animation : function () { 931 if(window.requestAnimationFrame) { 932 cancelAnimationFrame(this.ticker); 933 } else { 934 clearTimeout(this.ticker); 935 } 936 }, 937 938 move : function () { 939 var thisx = this.list.position().left, 940 thisy = this.list.position().top; 941 942 if (this.state === false) { 943 var abs_spdx = Math.abs(this.speedx), 944 abs_spdy = Math.abs(this.speedy); 945 946 if(this.opts.snap && this.opts.axis === "x" && abs_spdx < 10) { 947 this.stop_animation(); 948 this.go_page(this.get_nearby_page(thisx)); 949 return; 950 951 } else if(this.opts.snap && this.opts.axis === "y" && abs_spdy < 10) { 952 this.stop_animation(); 953 this.go_page(this.get_nearby_page(thisy)); 954 return; 955 956 } else if(abs_spdx < 1 && abs_spdy < 1) { 957 this.stop_animation(); 958 959 if(typeof(this.opts.stopped) === "function" && this.speedx !== 0) { 960 this.opts.stopped.call(this, this.get_event_data()); 961 } 962 963 this.scrollbar_pos(true); 964 return; 965 } else { 966 this.speedx = 0.95 * this.speedx; 967 this.speedy = 0.95 * this.speedy; 968 thisx += this.speedx; 969 thisy += this.speedy; 970 971 var x_chk = this.limit_chk({x:thisx}); 972 var x_limit = this.get_limit({x:thisx}); 973 var y_chk = this.limit_chk({y:thisy}); 974 var y_limit = this.get_limit({y:thisy}); 975 976 if(!x_chk || !y_chk) { 977 this.set_pos({x:thisx,y:thisy}); 978 979 if(Math.abs(thisx - x_limit) > 70) { 980 this.stop_animation(); 981 this.set_pos({x:x_limit}, this.duration); 982 return; 983 } 984 985 if(Math.abs(thisy - y_limit) > 70) { 986 this.stop_animation(); 987 this.set_pos({y:y_limit}, this.duration); 988 return; 989 } 990 } else { 991 this.set_pos({x:x_limit,y:y_limit}); 992 } 993 } 994 } else{ 995 this.tempx = thisx - this.prevx; 996 this.tempy = thisy - this.prevy; 997 this.prevx = thisx; 998 this.prevy = thisy; 999 } 1000 1001 this.scrollbar_pos(); 1002 this.start_animation(); 1003 }, 1004 1005 limit_chk : function (obj) { 1006 if(obj.x !== undefined) { 1007 return (obj.x > 0) === false && (obj.x < this.right) === false; 1008 } else if(obj.y !== undefined) { 1009 return (obj.y > 0) === false && (obj.y < this.bottom) === false; 1010 } 1011 }, 1012 1013 set_limit : function () { 1014 var listw = 0, 1015 listh = 0; 1016 this.wrapw = this.wrap.width(); 1017 this.wraph = this.wrap.height(); 1018 1019 $(this.list.children()).each(function () { 1020 listw += $(this).outerWidth(); 1021 listh += $(this).outerHeight(); 1022 }); 1023 this.listw = listw; 1024 this.listh = listh; 1025 1026 if(this.wrapw < this.listw) { 1027 this.right = -(this.listw - this.wrapw); 1028 } else if(this.wrapw > this.listw) { 1029 this.right = 0; 1030 } else { 1031 this.right = -this.listw; 1032 } 1033 1034 if(this.wraph < this.listh) { 1035 this.bottom = -(this.listh - this.wraph); 1036 } else if(this.wraph > this.listh) { 1037 this.bottom = 0; 1038 } else { 1039 this.bottom = -this.listh; 1040 } 1041 }, 1042 1043 get_limit : function (obj) { 1044 if(obj.x !== undefined) { 1045 if(obj.x > 0) { 1046 obj.x = 0; 1047 } 1048 if(obj.x < this.right) { 1049 obj.x = this.right; 1050 } 1051 return obj.x; 1052 } else if(obj.y !== undefined) { 1053 if(obj.y > 0) { 1054 obj.y = 0; 1055 } 1056 if(obj.y < this.bottom) { 1057 obj.y = this.bottom; 1058 } 1059 return obj.y; 1060 } 1061 }, 1062 1063 go_page : function (page) { 1064 var list_pos = this.list.offset(), 1065 pos = this.list.children().map(function() { 1066 return $(this).offset(); 1067 }); 1068 1069 this.opts.page = page; 1070 1071 if(this.opts.axis == "x") { 1072 var x = -((pos[page].left - list_pos.left) - (pos[0].left - list_pos.left)); 1073 this.posX(x); 1074 } else if(this.opts.axis == "y") { 1075 var y = -((pos[page].top - list_pos.top) - (pos[0].top - list_pos.top)); 1076 this.posY(y); 1077 } 1078 return this; 1079 }, 1080 1081 view_page : function (page) { 1082 this.opts.page = page; 1083 var tg = this.list.children().eq(page); 1084 1085 if(this.opts.axis == "x") { 1086 var x = tg.position().left, 1087 w = tg.width(), 1088 xside = this.wrapw * this.side, 1089 posX = this.posX(); 1090 1091 if(x + posX < 0) { 1092 x = -(x - xside); 1093 this.posX(x); 1094 } 1095 1096 if(x + w + posX > this.wrapw) { 1097 x = -(x + w - this.wrapw + xside); 1098 this.posX(x); 1099 } 1100 1101 } else if(this.opts.axis == "y") { 1102 var y = tg.position().top, 1103 h = tg.height(), 1104 yside = this.wraph * this.side, 1105 posY = this.posY(); 1106 1107 if(y + posY < 0) { 1108 y = -(y - yside); 1109 this.posY(y); 1110 } 1111 1112 if(y + h + posY > this.wraph) { 1113 y = -(y + h - this.wraph + yside); 1114 this.posY(y); 1115 } 1116 } 1117 1118 return this; 1119 }, 1120 1121 pos_control : function () { 1122 var thisx = this.posX(), 1123 thisy = this.posY(), 1124 x_chk = this.limit_chk({x:thisx}), 1125 x_limit = this.get_limit({x:thisx}), 1126 y_chk = this.limit_chk({y:thisy}), 1127 y_limit = this.get_limit({y:thisy}); 1128 1129 if(!x_chk || !y_chk) { 1130 this.set_pos({x:thisx,y:thisy}); 1131 1132 if(Math.abs(thisx - x_limit) > 70) { 1133 this.set_pos({x:x_limit}, this.duration); 1134 } 1135 1136 if(Math.abs(thisy - y_limit) > 70) { 1137 this.set_pos({y:y_limit}, this.duration); 1138 } 1139 } 1140 }, 1141 1142 set_pos : function (obj, duration) { 1143 obj = $.extend({}, {x:0,y:0}, obj); 1144 1145 var style = (supportsCssTransitions) ? { 1146 "transition" : (!duration) ? "0ms" : duration + "ms linear", 1147 "transform" : "translate3d(" + obj.x +"px, " + obj.y +"px, 0px)" 1148 } : { 1149 "left" : obj.x + "px", 1150 "top" : obj.y + "px" 1151 }; 1152 1153 this.list.css(style); 1154 }, 1155 1156 posX : function (val) { 1157 if(val !== undefined) { 1158 var to = this.get_limit({x:val}); 1159 if(val == "first") { 1160 to = 0; 1161 } else if(val == "last") { 1162 to = this.right; 1163 } 1164 this.stop_animation(); 1165 this.set_pos({x:to}, this.duration); 1166 1167 return this; 1168 } 1169 return this.list.position().left; 1170 }, 1171 1172 posY : function (val) { 1173 if(val !== undefined) { 1174 var to = this.get_limit({y:val}); 1175 if(val == "first") { 1176 to = 0; 1177 } else if(val == "last") { 1178 to = this.bottom; 1179 } 1180 this.stop_animation(); 1181 this.set_pos({y:to}, this.duration); 1182 1183 return this; 1184 } 1185 return this.list.position().top; 1186 }, 1187 1188 get_event_data : function () { 1189 return { 1190 obj : this, 1191 target : this.target, 1192 posX : this.posX(), 1193 posY : this.posY() 1194 }; 1195 } 1196 }; 1197 1198 $.fn.touchFlow = function (settings) { 1199 return this.each(function () { 1200 if (!$.data(this, 'touchFlow')) { 1201 $.data(this, 'touchFlow', new TouchFlow( this, settings )); 1202 } 1203 }); 1204 }; 1205})(jQuery); 1206 1207 1208 1209 1210/* 1211jquery.event.drag.js ~ v1.5 ~ Copyright (c) 2008, Three Dub Media (http://threedubmedia.com) 1212Liscensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-LICENSE.txt 1213v1.5.1 : jQuery 1.9 ì´ììì ëì ê°ë¥íëë¡ ìì (by dohoons) 1214*/ 1215(function(E){E.fn.drag=function(L,K,J){if(K){this.bind("dragstart",L)}if(J){this.bind("dragend",J)}return !L?this.trigger("drag"):this.bind("drag",K?K:L)};var A=E.event,B=A.special,F=B.drag={not:":input",distance:0,which:1,dragging:false,setup:function(J){J=E.extend({distance:F.distance,which:F.which,not:F.not},J||{});J.distance=I(J.distance);A.add(this,"mousedown",H,J);
1215if(this.attachEvent){this.attachEvent("ondragstart",D)}},teardown:function(){A.remove(this,"mousedown",H);if(this===F.dragging){F.dragging=F.proxy=false}G(this,true);if(this.detachEvent){this.detachEvent("ondragstart",D)}}};B.dragstart=B.dragend={setup:function(){},teardown:function(){}};function H(L){var K=this,J,M=L.data||{};if(M.elem){K=L.dragTarget=M.elem;L.dragProxy=F.proxy||K;L.cursorOffsetX=M.pageX-M.left;L.cursorOffsetY=M.pageY-M.top;L.offsetX=L.pageX-L.cursorOffsetX;L.offsetY=L.pageY-L.cursorOffsetY}else{if(F.dragging||(M.which>0&&L.which!=M.which)||E(L.target).is(M.not)){return }}switch(L.type){case"mousedown":E.extend(M,E(K).offset(),{elem:K,target:L.target,pageX:L.pageX,pageY:L.pageY});A.add(document,"mousemove mouseup",H,M);G(K,false);F.dragging=null;return false;case !F.dragging&&"mousemove":if(I(L.pageX-M.pageX)+I(L.pageY-M.pageY)<M.distance){break}L.target=M.target;J=C(L,"dragstart",K);if(J!==false){F.dragging=K;F.proxy=L.dragProxy=E(J||K)[0]}case"mousemove":if(F.dragging){J=C(L,"drag",K);if(B.drop){B.drop.allowed=(J!==false);B.drop.handler(L)}if(J!==false){break}L.type="mouseup"}case"mouseup":A.remove(document,"mousemove mouseup",H);if(F.dragging){if(B.drop){B.drop.handler(L)}C(L,"dragend",K)}G(K,true);F.dragging=F.proxy=M.elem=false;break}return true}function C(M,K,L){M.type=K;var J=E.event.dispatch.call(L,M);return J===false?false:J||M.result}function I(J){return Math.pow(J,2)}function D(){return(F.dragging===false)}function G(K,J){if(!K){return }K.unselectable=J?"off":"on";K.onselectstart=function(){return J};if(K.style){K.style.MozUserSelect=J?"":"none"}}})(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.