Changesets · Branches · Tags · Compare
| Changeset | 0e45921e04b7a0e4a3b00dda3347d9bcbb7c6b84ad9c2527ee69a6b4cce9aafd |
|---|---|
| Author | Matteo Spinelli <matteo@cubiq.org> · 2013-07-04 16:21 +02:00 |
| Committer | Matteo Spinelli <matteo@cubiq.org> · 2013-07-04 16:21 +02:00 |
| Parents | 944375a54929 |
17 files changed
modified build/iscroll-lite.js +50 −27
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | var IScroll = (function (window, document, Math) { |
| 3 | 3 | |
| 4 | 4 | var rAF = window.requestAnimationFrame || |
| @@ -283,6 +283,8 @@ | ||
| 283 | 283 | // Some defaults |
| 284 | 284 | this.x = 0; |
| 285 | 285 | this.y = 0; |
| 286 | + this.directionX = 0; | |
| 287 | + this.directionY = 0; | |
| 286 | 288 | this._events = {}; |
| 287 | 289 | |
| 288 | 290 | // INSERT POINT: DEFAULTS |
| @@ -295,7 +297,7 @@ | ||
| 295 | 297 | } |
| 296 | 298 | |
| 297 | 299 | IScroll.prototype = { |
| 298 | - version: '5.0.1', | |
| 300 | + version: '5.0.2', | |
| 299 | 301 | |
| 300 | 302 | _init: function () { |
| 301 | 303 | this._initEvents(); |
| @@ -322,6 +324,13 @@ | ||
| 322 | 324 | }, |
| 323 | 325 | |
| 324 | 326 | _start: function (e) { |
| 327 | + // React to left mouse button only | |
| 328 | + if ( utils.eventType[e.type] != 1 ) { | |
| 329 | + if ( e.button !== 0 ) { | |
| 330 | + return; | |
| 331 | + } | |
| 332 | + } | |
| 333 | + | |
| 325 | 334 | if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { |
| 326 | 335 | return; |
| 327 | 336 | } |
| @@ -353,12 +362,12 @@ | ||
| 353 | 362 | this.isInTransition = false; |
| 354 | 363 | } |
| 355 | 364 | |
| 356 | - this.startX = this.x; | |
| 357 | - this.startY = this.y; | |
| 365 | + this.startX = this.x; | |
| 366 | + this.startY = this.y; | |
| 358 | 367 | this.absStartX = this.x; |
| 359 | 368 | this.absStartY = this.y; |
| 360 | - this.pointX = point.pageX; | |
| 361 | - this.pointY = point.pageY; | |
| 369 | + this.pointX = point.pageX; | |
| 370 | + this.pointY = point.pageY; | |
| 362 | 371 | |
| 363 | 372 | this._execEvent('scrollStart'); |
| 364 | 373 | }, |
| @@ -373,8 +382,8 @@ | ||
| 373 | 382 | } |
| 374 | 383 | |
| 375 | 384 | var point = e.touches ? e.touches[0] : e, |
| 376 | - deltaX = point.pageX - this.pointX, | |
| 377 | - deltaY = point.pageY - this.pointY, | |
| 385 | + deltaX = this.hasHorizontalScroll ? point.pageX - this.pointX : 0, | |
| 386 | + deltaY = this.hasVerticalScroll ? point.pageY - this.pointY : 0, | |
| 378 | 387 | timestamp = utils.getTime(), |
| 379 | 388 | newX, newY, |
| 380 | 389 | absDistX, absDistY; |
| @@ -423,8 +432,8 @@ | ||
| 423 | 432 | deltaX = 0; |
| 424 | 433 | } |
| 425 | 434 | |
| 426 | - newX = this.x + (this.hasHorizontalScroll ? deltaX : 0); | |
| 427 | - newY = this.y + (this.hasVerticalScroll ? deltaY : 0); | |
| 435 | + newX = this.x + deltaX; | |
| 436 | + newY = this.y + deltaY; | |
| 428 | 437 | |
| 429 | 438 | // Slow down if outside of the boundaries |
| 430 | 439 | if ( newX > 0 || newX < this.maxScrollX ) { |
| @@ -523,6 +532,8 @@ | ||
| 523 | 532 | Math.min(distanceX, 1000) |
| 524 | 533 | ), 300); |
| 525 | 534 | |
| 535 | + this.directionX = 0; | |
| 536 | + this.directionY = 0; | |
| 526 | 537 | easing = this.options.bounceEasing; |
| 527 | 538 | } |
| 528 | 539 | |
| @@ -546,15 +557,10 @@ | ||
| 546 | 557 | |
| 547 | 558 | this.resizeTimeout = setTimeout(function () { |
| 548 | 559 | that.refresh(); |
| 549 | - that.resetPosition(); | |
| 550 | 560 | }, this.options.resizePolling); |
| 551 | 561 | }, |
| 552 | 562 | |
| 553 | 563 | resetPosition: function (time) { |
| 554 | - if ( this.x <= 0 && this.x >= this.maxScrollX && this.y <= 0 && this.y >= this.maxScrollY ) { | |
| 555 | - return false; | |
| 556 | - } | |
| 557 | - | |
| 558 | 564 | var x = this.x, |
| 559 | 565 | y = this.y; |
| 560 | 566 | |
| @@ -572,11 +578,8 @@ | ||
| 572 | 578 | y = this.maxScrollY; |
| 573 | 579 | } |
| 574 | 580 | |
| 575 | - if ( this.options.snap ) { | |
| 576 | - var snap = this._nearestSnap(x, y); | |
| 577 | - this.currentPage = snap; | |
| 578 | - x = snap.x; | |
| 579 | - y = snap.y; | |
| 581 | + if ( x == this.x && y == this.y ) { | |
| 582 | + return false; | |
| 580 | 583 | } |
| 581 | 584 | |
| 582 | 585 | this.scrollTo(x, y, time, this.options.bounceEasing); |
| @@ -608,22 +611,38 @@ | ||
| 608 | 611 | this.maxScrollX = this.wrapperWidth - this.scrollerWidth; |
| 609 | 612 | this.maxScrollY = this.wrapperHeight - this.scrollerHeight; |
| 610 | 613 | |
| 611 | - if ( this.maxScrollX > 0 ) { | |
| 614 | + this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 615 | + this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 616 | + | |
| 617 | + if ( !this.hasHorizontalScroll ) { | |
| 612 | 618 | this.maxScrollX = 0; |
| 619 | + this.scrollerWidth = this.wrapperWidth; | |
| 613 | 620 | } |
| 614 | 621 | |
| 615 | - if ( this.maxScrollY > 0 ) { | |
| 622 | + if ( !this.hasVerticalScroll ) { | |
| 616 | 623 | this.maxScrollY = 0; |
| 624 | + this.scrollerHeight = this.wrapperHeight; | |
| 617 | 625 | } |
| 618 | 626 | |
| 619 | - this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 620 | - this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 621 | - | |
| 622 | 627 | this.endTime = 0; |
| 628 | + this.directionX = 0; | |
| 629 | + this.directionY = 0; | |
| 623 | 630 | |
| 624 | 631 | this.wrapperOffset = utils.offset(this.wrapper); |
| 625 | 632 | |
| 626 | 633 | this._execEvent('refresh'); |
| 634 | + | |
| 635 | + this.resetPosition(); | |
| 636 | + | |
| 637 | + if ( this.options.snap ) { | |
| 638 | + var snap = this._nearestSnap(this.x, this.y); | |
| 639 | + if ( this.x == snap.x && this.y == snap.y ) { | |
| 640 | + return; | |
| 641 | + } | |
| 642 | + | |
| 643 | + this.currentPage = snap; | |
| 644 | + this.scrollTo(snap.x, snap.y); | |
| 645 | + } | |
| 627 | 646 | }, |
| 628 | 647 | |
| 629 | 648 | on: function (type, fn) { |
| @@ -697,7 +716,7 @@ | ||
| 697 | 716 | pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; |
| 698 | 717 | pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; |
| 699 | 718 | |
| 700 | - time = time === undefined || null || 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 719 | + time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 701 | 720 | |
| 702 | 721 | this.scrollTo(pos.left, pos.top, time, easing); |
| 703 | 722 | }, |
| @@ -803,7 +822,11 @@ | ||
| 803 | 822 | if ( now >= destTime ) { |
| 804 | 823 | that.isAnimating = false; |
| 805 | 824 | that._translate(destX, destY); |
| 806 | - that.resetPosition(that.options.bounceTime); | |
| 825 | + | |
| 826 | + if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 827 | + that._execEvent('scrollEnd'); | |
| 828 | + } | |
| 829 | + | |
| 807 | 830 | return; |
| 808 | 831 | } |
| 809 | 832 |
modified build/iscroll-probe.js +105 −65
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | var IScroll = (function (window, document, Math) { |
| 3 | 3 | |
| 4 | 4 | var rAF = window.requestAnimationFrame || |
| @@ -232,6 +232,8 @@ | ||
| 232 | 232 | |
| 233 | 233 | resizeIndicator: true, |
| 234 | 234 | |
| 235 | + mouseWheelSpeed: 20, | |
| 236 | + | |
| 235 | 237 | snapThreshold: 0.334, |
| 236 | 238 | |
| 237 | 239 | // INSERT POINT: OPTIONS |
| @@ -292,6 +294,8 @@ | ||
| 292 | 294 | // Some defaults |
| 293 | 295 | this.x = 0; |
| 294 | 296 | this.y = 0; |
| 297 | + this.directionX = 0; | |
| 298 | + this.directionY = 0; | |
| 295 | 299 | this._events = {}; |
| 296 | 300 | |
| 297 | 301 | // INSERT POINT: DEFAULTS |
| @@ -304,7 +308,7 @@ | ||
| 304 | 308 | } |
| 305 | 309 | |
| 306 | 310 | IScroll.prototype = { |
| 307 | - version: '5.0.1', | |
| 311 | + version: '5.0.2', | |
| 308 | 312 | |
| 309 | 313 | _init: function () { |
| 310 | 314 | this._initEvents(); |
| @@ -347,6 +351,13 @@ | ||
| 347 | 351 | }, |
| 348 | 352 | |
| 349 | 353 | _start: function (e) { |
| 354 | + // React to left mouse button only | |
| 355 | + if ( utils.eventType[e.type] != 1 ) { | |
| 356 | + if ( e.button !== 0 ) { | |
| 357 | + return; | |
| 358 | + } | |
| 359 | + } | |
| 360 | + | |
| 350 | 361 | if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { |
| 351 | 362 | return; |
| 352 | 363 | } |
| @@ -378,12 +389,12 @@ | ||
| 378 | 389 | this.isInTransition = false; |
| 379 | 390 | } |
| 380 | 391 | |
| 381 | - this.startX = this.x; | |
| 382 | - this.startY = this.y; | |
| 392 | + this.startX = this.x; | |
| 393 | + this.startY = this.y; | |
| 383 | 394 | this.absStartX = this.x; |
| 384 | 395 | this.absStartY = this.y; |
| 385 | - this.pointX = point.pageX; | |
| 386 | - this.pointY = point.pageY; | |
| 396 | + this.pointX = point.pageX; | |
| 397 | + this.pointY = point.pageY; | |
| 387 | 398 | |
| 388 | 399 | this._execEvent('scrollStart'); |
| 389 | 400 | }, |
| @@ -398,8 +409,8 @@ | ||
| 398 | 409 | } |
| 399 | 410 | |
| 400 | 411 | var point = e.touches ? e.touches[0] : e, |
| 401 | - deltaX = point.pageX - this.pointX, | |
| 402 | - deltaY = point.pageY - this.pointY, | |
| 412 | + deltaX = this.hasHorizontalScroll ? point.pageX - this.pointX : 0, | |
| 413 | + deltaY = this.hasVerticalScroll ? point.pageY - this.pointY : 0, | |
| 403 | 414 | timestamp = utils.getTime(), |
| 404 | 415 | newX, newY, |
| 405 | 416 | absDistX, absDistY; |
| @@ -448,8 +459,8 @@ | ||
| 448 | 459 | deltaX = 0; |
| 449 | 460 | } |
| 450 | 461 | |
| 451 | - newX = this.x + (this.hasHorizontalScroll ? deltaX : 0); | |
| 452 | - newY = this.y + (this.hasVerticalScroll ? deltaY : 0); | |
| 462 | + newX = this.x + deltaX; | |
| 463 | + newY = this.y + deltaY; | |
| 453 | 464 | |
| 454 | 465 | // Slow down if outside of the boundaries |
| 455 | 466 | if ( newX > 0 || newX < this.maxScrollX ) { |
| @@ -554,6 +565,8 @@ | ||
| 554 | 565 | Math.min(distanceX, 1000) |
| 555 | 566 | ), 300); |
| 556 | 567 | |
| 568 | + this.directionX = 0; | |
| 569 | + this.directionY = 0; | |
| 557 | 570 | easing = this.options.bounceEasing; |
| 558 | 571 | } |
| 559 | 572 | |
| @@ -577,15 +590,10 @@ | ||
| 577 | 590 | |
| 578 | 591 | this.resizeTimeout = setTimeout(function () { |
| 579 | 592 | that.refresh(); |
| 580 | - that.resetPosition(); | |
| 581 | 593 | }, this.options.resizePolling); |
| 582 | 594 | }, |
| 583 | 595 | |
| 584 | 596 | resetPosition: function (time) { |
| 585 | - if ( this.x <= 0 && this.x >= this.maxScrollX && this.y <= 0 && this.y >= this.maxScrollY ) { | |
| 586 | - return false; | |
| 587 | - } | |
| 588 | - | |
| 589 | 597 | var x = this.x, |
| 590 | 598 | y = this.y; |
| 591 | 599 | |
| @@ -603,11 +611,8 @@ | ||
| 603 | 611 | y = this.maxScrollY; |
| 604 | 612 | } |
| 605 | 613 | |
| 606 | - if ( this.options.snap ) { | |
| 607 | - var snap = this._nearestSnap(x, y); | |
| 608 | - this.currentPage = snap; | |
| 609 | - x = snap.x; | |
| 610 | - y = snap.y; | |
| 614 | + if ( x == this.x && y == this.y ) { | |
| 615 | + return false; | |
| 611 | 616 | } |
| 612 | 617 | |
| 613 | 618 | this.scrollTo(x, y, time, this.options.bounceEasing); |
| @@ -639,22 +644,38 @@ | ||
| 639 | 644 | this.maxScrollX = this.wrapperWidth - this.scrollerWidth; |
| 640 | 645 | this.maxScrollY = this.wrapperHeight - this.scrollerHeight; |
| 641 | 646 | |
| 642 | - if ( this.maxScrollX > 0 ) { | |
| 647 | + this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 648 | + this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 649 | + | |
| 650 | + if ( !this.hasHorizontalScroll ) { | |
| 643 | 651 | this.maxScrollX = 0; |
| 652 | + this.scrollerWidth = this.wrapperWidth; | |
| 644 | 653 | } |
| 645 | 654 | |
| 646 | - if ( this.maxScrollY > 0 ) { | |
| 655 | + if ( !this.hasVerticalScroll ) { | |
| 647 | 656 | this.maxScrollY = 0; |
| 657 | + this.scrollerHeight = this.wrapperHeight; | |
| 648 | 658 | } |
| 649 | 659 | |
| 650 | - this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 651 | - this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 652 | - | |
| 653 | 660 | this.endTime = 0; |
| 661 | + this.directionX = 0; | |
| 662 | + this.directionY = 0; | |
| 654 | 663 | |
| 655 | 664 | this.wrapperOffset = utils.offset(this.wrapper); |
| 656 | 665 | |
| 657 | 666 | this._execEvent('refresh'); |
| 667 | + | |
| 668 | + this.resetPosition(); | |
| 669 | + | |
| 670 | + if ( this.options.snap ) { | |
| 671 | + var snap = this._nearestSnap(this.x, this.y); | |
| 672 | + if ( this.x == snap.x && this.y == snap.y ) { | |
| 673 | + return; | |
| 674 | + } | |
| 675 | + | |
| 676 | + this.currentPage = snap; | |
| 677 | + this.scrollTo(snap.x, snap.y); | |
| 678 | + } | |
| 658 | 679 | }, |
| 659 | 680 | |
| 660 | 681 | on: function (type, fn) { |
| @@ -728,7 +749,7 @@ | ||
| 728 | 749 | pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; |
| 729 | 750 | pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; |
| 730 | 751 | |
| 731 | - time = time === undefined || null || 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 752 | + time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 732 | 753 | |
| 733 | 754 | this.scrollTo(pos.left, pos.top, time, easing); |
| 734 | 755 | }, |
| @@ -905,10 +926,12 @@ | ||
| 905 | 926 | this.on('destroy', function () { |
| 906 | 927 | if ( this.indicator1 ) { |
| 907 | 928 | this.indicator1.destroy(); |
| 929 | + this.indicator1 = null; | |
| 908 | 930 | } |
| 909 | 931 | |
| 910 | 932 | if ( this.indicator2 ) { |
| 911 | 933 | this.indicator2.destroy(); |
| 934 | + this.indicator2 = null; | |
| 912 | 935 | } |
| 913 | 936 | }); |
| 914 | 937 | }, |
| @@ -947,8 +970,8 @@ | ||
| 947 | 970 | return; |
| 948 | 971 | } |
| 949 | 972 | |
| 950 | - wheelDeltaX *= 10; | |
| 951 | - wheelDeltaY *= 10; | |
| 973 | + wheelDeltaX *= this.options.mouseWheelSpeed; | |
| 974 | + wheelDeltaY *= this.options.mouseWheelSpeed; | |
| 952 | 975 | |
| 953 | 976 | if ( !this.hasVerticalScroll ) { |
| 954 | 977 | wheelDeltaX = wheelDeltaY; |
| @@ -979,7 +1002,6 @@ | ||
| 979 | 1002 | }, |
| 980 | 1003 | |
| 981 | 1004 | _initSnap: function () { |
| 982 | - this.pages = []; | |
| 983 | 1005 | this.currentPage = {}; |
| 984 | 1006 | |
| 985 | 1007 | if ( typeof this.options.snap == 'string' ) { |
| @@ -995,6 +1017,8 @@ | ||
| 995 | 1017 | stepY = this.options.snapStepY || this.wrapperHeight, |
| 996 | 1018 | el; |
| 997 | 1019 | |
| 1020 | + this.pages = []; | |
| 1021 | + | |
| 998 | 1022 | if ( this.options.snap === true ) { |
| 999 | 1023 | cx = Math.round( stepX / 2 ); |
| 1000 | 1024 | cy = Math.round( stepY / 2 ); |
| @@ -1050,7 +1074,9 @@ | ||
| 1050 | 1074 | cy: cy |
| 1051 | 1075 | }; |
| 1052 | 1076 | |
| 1053 | - m++; | |
| 1077 | + if ( x > this.maxScrollX ) { | |
| 1078 | + m++; | |
| 1079 | + } | |
| 1054 | 1080 | } |
| 1055 | 1081 | } |
| 1056 | 1082 | |
| @@ -1086,6 +1112,7 @@ | ||
| 1086 | 1112 | l = this.pages.length, |
| 1087 | 1113 | m = 0; |
| 1088 | 1114 | |
| 1115 | + // Check if we exceeded the snap threshold | |
| 1089 | 1116 | if ( Math.abs(x - this.absStartX) < this.snapThresholdX && |
| 1090 | 1117 | Math.abs(y - this.absStartY) < this.snapThresholdY ) { |
| 1091 | 1118 | return this.currentPage; |
| @@ -1330,47 +1357,47 @@ | ||
| 1330 | 1357 | this.keyTime = now; |
| 1331 | 1358 | }, |
| 1332 | 1359 | |
| 1333 | -_animate: function (destX, destY, duration, easingFn) { | |
| 1334 | - var that = this, | |
| 1335 | - startX = this.x, | |
| 1336 | - startY = this.y, | |
| 1337 | - startTime = utils.getTime(), | |
| 1338 | - destTime = startTime + duration; | |
| 1360 | + _animate: function (destX, destY, duration, easingFn) { | |
| 1361 | + var that = this, | |
| 1362 | + startX = this.x, | |
| 1363 | + startY = this.y, | |
| 1364 | + startTime = utils.getTime(), | |
| 1365 | + destTime = startTime + duration; | |
| 1366 | + | |
| 1367 | + function step () { | |
| 1368 | + var now = utils.getTime(), | |
| 1369 | + newX, newY, | |
| 1370 | + easing; | |
| 1371 | + | |
| 1372 | + if ( now >= destTime ) { | |
| 1373 | + that.isAnimating = false; | |
| 1374 | + that._translate(destX, destY); | |
| 1375 | + | |
| 1376 | + if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 1377 | + that._execEvent('scrollEnd'); | |
| 1378 | + } | |
| 1339 | 1379 | |
| 1340 | - function step () { | |
| 1341 | - var now = utils.getTime(), | |
| 1342 | - newX, newY, | |
| 1343 | - easing; | |
| 1344 | - | |
| 1345 | - if ( now >= destTime ) { | |
| 1346 | - that.isAnimating = false; | |
| 1347 | - that._translate(destX, destY); | |
| 1348 | - | |
| 1349 | - if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 1350 | - that._execEvent('scrollEnd'); | |
| 1380 | + return; | |
| 1351 | 1381 | } |
| 1352 | 1382 | |
| 1353 | - return; | |
| 1354 | - } | |
| 1355 | - | |
| 1356 | - now = ( now - startTime ) / duration; | |
| 1357 | - easing = easingFn(now); | |
| 1358 | - newX = ( destX - startX ) * easing + startX; | |
| 1359 | - newY = ( destY - startY ) * easing + startY; | |
| 1360 | - that._translate(newX, newY); | |
| 1361 | - | |
| 1362 | - if ( that.isAnimating ) { | |
| 1363 | - rAF(step); | |
| 1364 | - } | |
| 1383 | + now = ( now - startTime ) / duration; | |
| 1384 | + easing = easingFn(now); | |
| 1385 | + newX = ( destX - startX ) * easing + startX; | |
| 1386 | + newY = ( destY - startY ) * easing + startY; | |
| 1387 | + that._translate(newX, newY); | |
| 1388 | + | |
| 1389 | + if ( that.isAnimating ) { | |
| 1390 | + rAF(step); | |
| 1391 | + } | |
| 1365 | 1392 | |
| 1366 | - if ( that.options.probeType == 3 ) { | |
| 1367 | - that._execEvent('scroll'); | |
| 1393 | + if ( that.options.probeType == 3 ) { | |
| 1394 | + that._execEvent('scroll'); | |
| 1395 | + } | |
| 1368 | 1396 | } |
| 1369 | - } | |
| 1370 | 1397 | |
| 1371 | - this.isAnimating = true; | |
| 1372 | - step(); | |
| 1373 | -}, | |
| 1398 | + this.isAnimating = true; | |
| 1399 | + step(); | |
| 1400 | + }, | |
| 1374 | 1401 | |
| 1375 | 1402 | handleEvent: function (e) { |
| 1376 | 1403 | switch ( e.type ) { |
| @@ -1520,6 +1547,10 @@ | ||
| 1520 | 1547 | utils.removeEvent(window, 'MSPointerUp', this); |
| 1521 | 1548 | utils.removeEvent(window, 'mouseup', this); |
| 1522 | 1549 | } |
| 1550 | + | |
| 1551 | + if ( this.options.defaultScrollbars ) { | |
| 1552 | + this.wrapper.parentNode.removeChild(this.wrapper); | |
| 1553 | + } | |
| 1523 | 1554 | }, |
| 1524 | 1555 | |
| 1525 | 1556 | _start: function (e) { |
| @@ -1531,6 +1562,7 @@ | ||
| 1531 | 1562 | this.transitionTime(0); |
| 1532 | 1563 | |
| 1533 | 1564 | this.initiated = true; |
| 1565 | + this.moved = false; | |
| 1534 | 1566 | this.lastPointX = point.pageX; |
| 1535 | 1567 | this.lastPointY = point.pageY; |
| 1536 | 1568 | |
| @@ -1539,6 +1571,8 @@ | ||
| 1539 | 1571 | utils.addEvent(window, 'touchmove', this); |
| 1540 | 1572 | utils.addEvent(window, 'MSPointerMove', this); |
| 1541 | 1573 | utils.addEvent(window, 'mousemove', this); |
| 1574 | + | |
| 1575 | + this.scroller._execEvent('scrollStart'); | |
| 1542 | 1576 | }, |
| 1543 | 1577 | |
| 1544 | 1578 | _move: function (e) { |
| @@ -1547,6 +1581,8 @@ | ||
| 1547 | 1581 | newX, newY, |
| 1548 | 1582 | timestamp = utils.getTime(); |
| 1549 | 1583 | |
| 1584 | + this.moved = true; | |
| 1585 | + | |
| 1550 | 1586 | deltaX = point.pageX - this.lastPointX; |
| 1551 | 1587 | this.lastPointX = point.pageX; |
| 1552 | 1588 | |
| @@ -1575,6 +1611,10 @@ | ||
| 1575 | 1611 | utils.removeEvent(window, 'touchmove', this); |
| 1576 | 1612 | utils.removeEvent(window, 'MSPointerMove', this); |
| 1577 | 1613 | utils.removeEvent(window, 'mousemove', this); |
| 1614 | + | |
| 1615 | + if ( this.moved ) { | |
| 1616 | + this.scroller._execEvent('scrollEnd'); | |
| 1617 | + } | |
| 1578 | 1618 | }, |
| 1579 | 1619 | |
| 1580 | 1620 | transitionTime: function (time) { |
modified build/iscroll-zoom.js +75 −31
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | var IScroll = (function (window, document, Math) { |
| 3 | 3 | |
| 4 | 4 | var rAF = window.requestAnimationFrame || |
| @@ -235,6 +235,8 @@ | ||
| 235 | 235 | |
| 236 | 236 | resizeIndicator: true, |
| 237 | 237 | |
| 238 | + mouseWheelSpeed: 20, | |
| 239 | + | |
| 238 | 240 | snapThreshold: 0.334, |
| 239 | 241 | |
| 240 | 242 | // INSERT POINT: OPTIONS |
| @@ -292,6 +294,8 @@ | ||
| 292 | 294 | // Some defaults |
| 293 | 295 | this.x = 0; |
| 294 | 296 | this.y = 0; |
| 297 | + this.directionX = 0; | |
| 298 | + this.directionY = 0; | |
| 295 | 299 | this._events = {}; |
| 296 | 300 | |
| 297 | 301 | this.scale = 1; |
| @@ -306,7 +310,7 @@ | ||
| 306 | 310 | } |
| 307 | 311 | |
| 308 | 312 | IScroll.prototype = { |
| 309 | - version: '5.0.1', | |
| 313 | + version: '5.0.2', | |
| 310 | 314 | |
| 311 | 315 | _init: function () { |
| 312 | 316 | this._initEvents(); |
| @@ -353,6 +357,13 @@ | ||
| 353 | 357 | }, |
| 354 | 358 | |
| 355 | 359 | _start: function (e) { |
| 360 | + // React to left mouse button only | |
| 361 | + if ( utils.eventType[e.type] != 1 ) { | |
| 362 | + if ( e.button !== 0 ) { | |
| 363 | + return; | |
| 364 | + } | |
| 365 | + } | |
| 366 | + | |
| 356 | 367 | if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { |
| 357 | 368 | return; |
| 358 | 369 | } |
| @@ -384,12 +395,12 @@ | ||
| 384 | 395 | this.isInTransition = false; |
| 385 | 396 | } |
| 386 | 397 | |
| 387 | - this.startX = this.x; | |
| 388 | - this.startY = this.y; | |
| 398 | + this.startX = this.x; | |
| 399 | + this.startY = this.y; | |
| 389 | 400 | this.absStartX = this.x; |
| 390 | 401 | this.absStartY = this.y; |
| 391 | - this.pointX = point.pageX; | |
| 392 | - this.pointY = point.pageY; | |
| 402 | + this.pointX = point.pageX; | |
| 403 | + this.pointY = point.pageY; | |
| 393 | 404 | |
| 394 | 405 | this._execEvent('scrollStart'); |
| 395 | 406 | }, |
| @@ -404,8 +415,8 @@ | ||
| 404 | 415 | } |
| 405 | 416 | |
| 406 | 417 | var point = e.touches ? e.touches[0] : e, |
| 407 | - deltaX = point.pageX - this.pointX, | |
| 408 | - deltaY = point.pageY - this.pointY, | |
| 418 | + deltaX = this.hasHorizontalScroll ? point.pageX - this.pointX : 0, | |
| 419 | + deltaY = this.hasVerticalScroll ? point.pageY - this.pointY : 0, | |
| 409 | 420 | timestamp = utils.getTime(), |
| 410 | 421 | newX, newY, |
| 411 | 422 | absDistX, absDistY; |
| @@ -454,8 +465,8 @@ | ||
| 454 | 465 | deltaX = 0; |
| 455 | 466 | } |
| 456 | 467 | |
| 457 | - newX = this.x + (this.hasHorizontalScroll ? deltaX : 0); | |
| 458 | - newY = this.y + (this.hasVerticalScroll ? deltaY : 0); | |
| 468 | + newX = this.x + deltaX; | |
| 469 | + newY = this.y + deltaY; | |
| 459 | 470 | |
| 460 | 471 | // Slow down if outside of the boundaries |
| 461 | 472 | if ( newX > 0 || newX < this.maxScrollX ) { |
| @@ -554,6 +565,8 @@ | ||
| 554 | 565 | Math.min(distanceX, 1000) |
| 555 | 566 | ), 300); |
| 556 | 567 | |
| 568 | + this.directionX = 0; | |
| 569 | + this.directionY = 0; | |
| 557 | 570 | easing = this.options.bounceEasing; |
| 558 | 571 | } |
| 559 | 572 | |
| @@ -577,15 +590,10 @@ | ||
| 577 | 590 | |
| 578 | 591 | this.resizeTimeout = setTimeout(function () { |
| 579 | 592 | that.refresh(); |
| 580 | - that.resetPosition(); | |
| 581 | 593 | }, this.options.resizePolling); |
| 582 | 594 | }, |
| 583 | 595 | |
| 584 | 596 | resetPosition: function (time) { |
| 585 | - if ( this.x <= 0 && this.x >= this.maxScrollX && this.y <= 0 && this.y >= this.maxScrollY ) { | |
| 586 | - return false; | |
| 587 | - } | |
| 588 | - | |
| 589 | 597 | var x = this.x, |
| 590 | 598 | y = this.y; |
| 591 | 599 | |
| @@ -603,11 +611,8 @@ | ||
| 603 | 611 | y = this.maxScrollY; |
| 604 | 612 | } |
| 605 | 613 | |
| 606 | - if ( this.options.snap ) { | |
| 607 | - var snap = this._nearestSnap(x, y); | |
| 608 | - this.currentPage = snap; | |
| 609 | - x = snap.x; | |
| 610 | - y = snap.y; | |
| 614 | + if ( x == this.x && y == this.y ) { | |
| 615 | + return false; | |
| 611 | 616 | } |
| 612 | 617 | |
| 613 | 618 | this.scrollTo(x, y, time, this.options.bounceEasing); |
| @@ -637,22 +642,38 @@ | ||
| 637 | 642 | this.maxScrollX = this.wrapperWidth - this.scrollerWidth; |
| 638 | 643 | this.maxScrollY = this.wrapperHeight - this.scrollerHeight; |
| 639 | 644 | |
| 640 | - if ( this.maxScrollX > 0 ) { | |
| 645 | + this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 646 | + this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 647 | + | |
| 648 | + if ( !this.hasHorizontalScroll ) { | |
| 641 | 649 | this.maxScrollX = 0; |
| 650 | + this.scrollerWidth = this.wrapperWidth; | |
| 642 | 651 | } |
| 643 | 652 | |
| 644 | - if ( this.maxScrollY > 0 ) { | |
| 653 | + if ( !this.hasVerticalScroll ) { | |
| 645 | 654 | this.maxScrollY = 0; |
| 655 | + this.scrollerHeight = this.wrapperHeight; | |
| 646 | 656 | } |
| 647 | 657 | |
| 648 | - this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 649 | - this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 650 | - | |
| 651 | 658 | this.endTime = 0; |
| 659 | + this.directionX = 0; | |
| 660 | + this.directionY = 0; | |
| 652 | 661 | |
| 653 | 662 | this.wrapperOffset = utils.offset(this.wrapper); |
| 654 | 663 | |
| 655 | 664 | this._execEvent('refresh'); |
| 665 | + | |
| 666 | + this.resetPosition(); | |
| 667 | + | |
| 668 | + if ( this.options.snap ) { | |
| 669 | + var snap = this._nearestSnap(this.x, this.y); | |
| 670 | + if ( this.x == snap.x && this.y == snap.y ) { | |
| 671 | + return; | |
| 672 | + } | |
| 673 | + | |
| 674 | + this.currentPage = snap; | |
| 675 | + this.scrollTo(snap.x, snap.y); | |
| 676 | + } | |
| 656 | 677 | }, |
| 657 | 678 | |
| 658 | 679 | on: function (type, fn) { |
| @@ -726,7 +747,7 @@ | ||
| 726 | 747 | pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; |
| 727 | 748 | pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; |
| 728 | 749 | |
| 729 | - time = time === undefined || null || 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 750 | + time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 730 | 751 | |
| 731 | 752 | this.scrollTo(pos.left, pos.top, time, easing); |
| 732 | 753 | }, |
| @@ -899,10 +920,12 @@ | ||
| 899 | 920 | this.on('destroy', function () { |
| 900 | 921 | if ( this.indicator1 ) { |
| 901 | 922 | this.indicator1.destroy(); |
| 923 | + this.indicator1 = null; | |
| 902 | 924 | } |
| 903 | 925 | |
| 904 | 926 | if ( this.indicator2 ) { |
| 905 | 927 | this.indicator2.destroy(); |
| 928 | + this.indicator2 = null; | |
| 906 | 929 | } |
| 907 | 930 | }); |
| 908 | 931 | }, |
| @@ -1102,8 +1125,8 @@ | ||
| 1102 | 1125 | return; |
| 1103 | 1126 | } |
| 1104 | 1127 | |
| 1105 | - wheelDeltaX *= 10; | |
| 1106 | - wheelDeltaY *= 10; | |
| 1128 | + wheelDeltaX *= this.options.mouseWheelSpeed; | |
| 1129 | + wheelDeltaY *= this.options.mouseWheelSpeed; | |
| 1107 | 1130 | |
| 1108 | 1131 | if ( !this.hasVerticalScroll ) { |
| 1109 | 1132 | wheelDeltaX = wheelDeltaY; |
| @@ -1130,7 +1153,6 @@ | ||
| 1130 | 1153 | }, |
| 1131 | 1154 | |
| 1132 | 1155 | _initSnap: function () { |
| 1133 | - this.pages = []; | |
| 1134 | 1156 | this.currentPage = {}; |
| 1135 | 1157 | |
| 1136 | 1158 | if ( typeof this.options.snap == 'string' ) { |
| @@ -1146,6 +1168,8 @@ | ||
| 1146 | 1168 | stepY = this.options.snapStepY || this.wrapperHeight, |
| 1147 | 1169 | el; |
| 1148 | 1170 | |
| 1171 | + this.pages = []; | |
| 1172 | + | |
| 1149 | 1173 | if ( this.options.snap === true ) { |
| 1150 | 1174 | cx = Math.round( stepX / 2 ); |
| 1151 | 1175 | cy = Math.round( stepY / 2 ); |
| @@ -1201,7 +1225,9 @@ | ||
| 1201 | 1225 | cy: cy |
| 1202 | 1226 | }; |
| 1203 | 1227 | |
| 1204 | - m++; | |
| 1228 | + if ( x > this.maxScrollX ) { | |
| 1229 | + m++; | |
| 1230 | + } | |
| 1205 | 1231 | } |
| 1206 | 1232 | } |
| 1207 | 1233 | |
| @@ -1237,6 +1263,7 @@ | ||
| 1237 | 1263 | l = this.pages.length, |
| 1238 | 1264 | m = 0; |
| 1239 | 1265 | |
| 1266 | + // Check if we exceeded the snap threshold | |
| 1240 | 1267 | if ( Math.abs(x - this.absStartX) < this.snapThresholdX && |
| 1241 | 1268 | Math.abs(y - this.absStartY) < this.snapThresholdY ) { |
| 1242 | 1269 | return this.currentPage; |
| @@ -1496,7 +1523,11 @@ | ||
| 1496 | 1523 | if ( now >= destTime ) { |
| 1497 | 1524 | that.isAnimating = false; |
| 1498 | 1525 | that._translate(destX, destY); |
| 1499 | - that.resetPosition(that.options.bounceTime); | |
| 1526 | + | |
| 1527 | + if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 1528 | + that._execEvent('scrollEnd'); | |
| 1529 | + } | |
| 1530 | + | |
| 1500 | 1531 | return; |
| 1501 | 1532 | } |
| 1502 | 1533 | |
| @@ -1679,6 +1710,10 @@ | ||
| 1679 | 1710 | utils.removeEvent(window, 'MSPointerUp', this); |
| 1680 | 1711 | utils.removeEvent(window, 'mouseup', this); |
| 1681 | 1712 | } |
| 1713 | + | |
| 1714 | + if ( this.options.defaultScrollbars ) { | |
| 1715 | + this.wrapper.parentNode.removeChild(this.wrapper); | |
| 1716 | + } | |
| 1682 | 1717 | }, |
| 1683 | 1718 | |
| 1684 | 1719 | _start: function (e) { |
| @@ -1690,6 +1725,7 @@ | ||
| 1690 | 1725 | this.transitionTime(0); |
| 1691 | 1726 | |
| 1692 | 1727 | this.initiated = true; |
| 1728 | + this.moved = false; | |
| 1693 | 1729 | this.lastPointX = point.pageX; |
| 1694 | 1730 | this.lastPointY = point.pageY; |
| 1695 | 1731 | |
| @@ -1698,6 +1734,8 @@ | ||
| 1698 | 1734 | utils.addEvent(window, 'touchmove', this); |
| 1699 | 1735 | utils.addEvent(window, 'MSPointerMove', this); |
| 1700 | 1736 | utils.addEvent(window, 'mousemove', this); |
| 1737 | + | |
| 1738 | + this.scroller._execEvent('scrollStart'); | |
| 1701 | 1739 | }, |
| 1702 | 1740 | |
| 1703 | 1741 | _move: function (e) { |
| @@ -1706,6 +1744,8 @@ | ||
| 1706 | 1744 | newX, newY, |
| 1707 | 1745 | timestamp = utils.getTime(); |
| 1708 | 1746 | |
| 1747 | + this.moved = true; | |
| 1748 | + | |
| 1709 | 1749 | deltaX = point.pageX - this.lastPointX; |
| 1710 | 1750 | this.lastPointX = point.pageX; |
| 1711 | 1751 | |
| @@ -1734,6 +1774,10 @@ | ||
| 1734 | 1774 | utils.removeEvent(window, 'touchmove', this); |
| 1735 | 1775 | utils.removeEvent(window, 'MSPointerMove', this); |
| 1736 | 1776 | utils.removeEvent(window, 'mousemove', this); |
| 1777 | + | |
| 1778 | + if ( this.moved ) { | |
| 1779 | + this.scroller._execEvent('scrollEnd'); | |
| 1780 | + } | |
| 1737 | 1781 | }, |
| 1738 | 1782 | |
| 1739 | 1783 | transitionTime: function (time) { |
modified build/iscroll.js +75 −31
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | var IScroll = (function (window, document, Math) { |
| 3 | 3 | |
| 4 | 4 | var rAF = window.requestAnimationFrame || |
| @@ -232,6 +232,8 @@ | ||
| 232 | 232 | |
| 233 | 233 | resizeIndicator: true, |
| 234 | 234 | |
| 235 | + mouseWheelSpeed: 20, | |
| 236 | + | |
| 235 | 237 | snapThreshold: 0.334, |
| 236 | 238 | |
| 237 | 239 | // INSERT POINT: OPTIONS |
| @@ -289,6 +291,8 @@ | ||
| 289 | 291 | // Some defaults |
| 290 | 292 | this.x = 0; |
| 291 | 293 | this.y = 0; |
| 294 | + this.directionX = 0; | |
| 295 | + this.directionY = 0; | |
| 292 | 296 | this._events = {}; |
| 293 | 297 | |
| 294 | 298 | // INSERT POINT: DEFAULTS |
| @@ -301,7 +305,7 @@ | ||
| 301 | 305 | } |
| 302 | 306 | |
| 303 | 307 | IScroll.prototype = { |
| 304 | - version: '5.0.1', | |
| 308 | + version: '5.0.2', | |
| 305 | 309 | |
| 306 | 310 | _init: function () { |
| 307 | 311 | this._initEvents(); |
| @@ -344,6 +348,13 @@ | ||
| 344 | 348 | }, |
| 345 | 349 | |
| 346 | 350 | _start: function (e) { |
| 351 | + // React to left mouse button only | |
| 352 | + if ( utils.eventType[e.type] != 1 ) { | |
| 353 | + if ( e.button !== 0 ) { | |
| 354 | + return; | |
| 355 | + } | |
| 356 | + } | |
| 357 | + | |
| 347 | 358 | if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { |
| 348 | 359 | return; |
| 349 | 360 | } |
| @@ -375,12 +386,12 @@ | ||
| 375 | 386 | this.isInTransition = false; |
| 376 | 387 | } |
| 377 | 388 | |
| 378 | - this.startX = this.x; | |
| 379 | - this.startY = this.y; | |
| 389 | + this.startX = this.x; | |
| 390 | + this.startY = this.y; | |
| 380 | 391 | this.absStartX = this.x; |
| 381 | 392 | this.absStartY = this.y; |
| 382 | - this.pointX = point.pageX; | |
| 383 | - this.pointY = point.pageY; | |
| 393 | + this.pointX = point.pageX; | |
| 394 | + this.pointY = point.pageY; | |
| 384 | 395 | |
| 385 | 396 | this._execEvent('scrollStart'); |
| 386 | 397 | }, |
| @@ -395,8 +406,8 @@ | ||
| 395 | 406 | } |
| 396 | 407 | |
| 397 | 408 | var point = e.touches ? e.touches[0] : e, |
| 398 | - deltaX = point.pageX - this.pointX, | |
| 399 | - deltaY = point.pageY - this.pointY, | |
| 409 | + deltaX = this.hasHorizontalScroll ? point.pageX - this.pointX : 0, | |
| 410 | + deltaY = this.hasVerticalScroll ? point.pageY - this.pointY : 0, | |
| 400 | 411 | timestamp = utils.getTime(), |
| 401 | 412 | newX, newY, |
| 402 | 413 | absDistX, absDistY; |
| @@ -445,8 +456,8 @@ | ||
| 445 | 456 | deltaX = 0; |
| 446 | 457 | } |
| 447 | 458 | |
| 448 | - newX = this.x + (this.hasHorizontalScroll ? deltaX : 0); | |
| 449 | - newY = this.y + (this.hasVerticalScroll ? deltaY : 0); | |
| 459 | + newX = this.x + deltaX; | |
| 460 | + newY = this.y + deltaY; | |
| 450 | 461 | |
| 451 | 462 | // Slow down if outside of the boundaries |
| 452 | 463 | if ( newX > 0 || newX < this.maxScrollX ) { |
| @@ -545,6 +556,8 @@ | ||
| 545 | 556 | Math.min(distanceX, 1000) |
| 546 | 557 | ), 300); |
| 547 | 558 | |
| 559 | + this.directionX = 0; | |
| 560 | + this.directionY = 0; | |
| 548 | 561 | easing = this.options.bounceEasing; |
| 549 | 562 | } |
| 550 | 563 | |
| @@ -568,15 +581,10 @@ | ||
| 568 | 581 | |
| 569 | 582 | this.resizeTimeout = setTimeout(function () { |
| 570 | 583 | that.refresh(); |
| 571 | - that.resetPosition(); | |
| 572 | 584 | }, this.options.resizePolling); |
| 573 | 585 | }, |
| 574 | 586 | |
| 575 | 587 | resetPosition: function (time) { |
| 576 | - if ( this.x <= 0 && this.x >= this.maxScrollX && this.y <= 0 && this.y >= this.maxScrollY ) { | |
| 577 | - return false; | |
| 578 | - } | |
| 579 | - | |
| 580 | 588 | var x = this.x, |
| 581 | 589 | y = this.y; |
| 582 | 590 | |
| @@ -594,11 +602,8 @@ | ||
| 594 | 602 | y = this.maxScrollY; |
| 595 | 603 | } |
| 596 | 604 | |
| 597 | - if ( this.options.snap ) { | |
| 598 | - var snap = this._nearestSnap(x, y); | |
| 599 | - this.currentPage = snap; | |
| 600 | - x = snap.x; | |
| 601 | - y = snap.y; | |
| 605 | + if ( x == this.x && y == this.y ) { | |
| 606 | + return false; | |
| 602 | 607 | } |
| 603 | 608 | |
| 604 | 609 | this.scrollTo(x, y, time, this.options.bounceEasing); |
| @@ -630,22 +635,38 @@ | ||
| 630 | 635 | this.maxScrollX = this.wrapperWidth - this.scrollerWidth; |
| 631 | 636 | this.maxScrollY = this.wrapperHeight - this.scrollerHeight; |
| 632 | 637 | |
| 633 | - if ( this.maxScrollX > 0 ) { | |
| 638 | + this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 639 | + this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 640 | + | |
| 641 | + if ( !this.hasHorizontalScroll ) { | |
| 634 | 642 | this.maxScrollX = 0; |
| 643 | + this.scrollerWidth = this.wrapperWidth; | |
| 635 | 644 | } |
| 636 | 645 | |
| 637 | - if ( this.maxScrollY > 0 ) { | |
| 646 | + if ( !this.hasVerticalScroll ) { | |
| 638 | 647 | this.maxScrollY = 0; |
| 648 | + this.scrollerHeight = this.wrapperHeight; | |
| 639 | 649 | } |
| 640 | 650 | |
| 641 | - this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 642 | - this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 643 | - | |
| 644 | 651 | this.endTime = 0; |
| 652 | + this.directionX = 0; | |
| 653 | + this.directionY = 0; | |
| 645 | 654 | |
| 646 | 655 | this.wrapperOffset = utils.offset(this.wrapper); |
| 647 | 656 | |
| 648 | 657 | this._execEvent('refresh'); |
| 658 | + | |
| 659 | + this.resetPosition(); | |
| 660 | + | |
| 661 | + if ( this.options.snap ) { | |
| 662 | + var snap = this._nearestSnap(this.x, this.y); | |
| 663 | + if ( this.x == snap.x && this.y == snap.y ) { | |
| 664 | + return; | |
| 665 | + } | |
| 666 | + | |
| 667 | + this.currentPage = snap; | |
| 668 | + this.scrollTo(snap.x, snap.y); | |
| 669 | + } | |
| 649 | 670 | }, |
| 650 | 671 | |
| 651 | 672 | on: function (type, fn) { |
| @@ -719,7 +740,7 @@ | ||
| 719 | 740 | pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; |
| 720 | 741 | pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; |
| 721 | 742 | |
| 722 | - time = time === undefined || null || 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 743 | + time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 723 | 744 | |
| 724 | 745 | this.scrollTo(pos.left, pos.top, time, easing); |
| 725 | 746 | }, |
| @@ -896,10 +917,12 @@ | ||
| 896 | 917 | this.on('destroy', function () { |
| 897 | 918 | if ( this.indicator1 ) { |
| 898 | 919 | this.indicator1.destroy(); |
| 920 | + this.indicator1 = null; | |
| 899 | 921 | } |
| 900 | 922 | |
| 901 | 923 | if ( this.indicator2 ) { |
| 902 | 924 | this.indicator2.destroy(); |
| 925 | + this.indicator2 = null; | |
| 903 | 926 | } |
| 904 | 927 | }); |
| 905 | 928 | }, |
| @@ -938,8 +961,8 @@ | ||
| 938 | 961 | return; |
| 939 | 962 | } |
| 940 | 963 | |
| 941 | - wheelDeltaX *= 10; | |
| 942 | - wheelDeltaY *= 10; | |
| 964 | + wheelDeltaX *= this.options.mouseWheelSpeed; | |
| 965 | + wheelDeltaY *= this.options.mouseWheelSpeed; | |
| 943 | 966 | |
| 944 | 967 | if ( !this.hasVerticalScroll ) { |
| 945 | 968 | wheelDeltaX = wheelDeltaY; |
| @@ -966,7 +989,6 @@ | ||
| 966 | 989 | }, |
| 967 | 990 | |
| 968 | 991 | _initSnap: function () { |
| 969 | - this.pages = []; | |
| 970 | 992 | this.currentPage = {}; |
| 971 | 993 | |
| 972 | 994 | if ( typeof this.options.snap == 'string' ) { |
| @@ -982,6 +1004,8 @@ | ||
| 982 | 1004 | stepY = this.options.snapStepY || this.wrapperHeight, |
| 983 | 1005 | el; |
| 984 | 1006 | |
| 1007 | + this.pages = []; | |
| 1008 | + | |
| 985 | 1009 | if ( this.options.snap === true ) { |
| 986 | 1010 | cx = Math.round( stepX / 2 ); |
| 987 | 1011 | cy = Math.round( stepY / 2 ); |
| @@ -1037,7 +1061,9 @@ | ||
| 1037 | 1061 | cy: cy |
| 1038 | 1062 | }; |
| 1039 | 1063 | |
| 1040 | - m++; | |
| 1064 | + if ( x > this.maxScrollX ) { | |
| 1065 | + m++; | |
| 1066 | + } | |
| 1041 | 1067 | } |
| 1042 | 1068 | } |
| 1043 | 1069 | |
| @@ -1073,6 +1099,7 @@ | ||
| 1073 | 1099 | l = this.pages.length, |
| 1074 | 1100 | m = 0; |
| 1075 | 1101 | |
| 1102 | + // Check if we exceeded the snap threshold | |
| 1076 | 1103 | if ( Math.abs(x - this.absStartX) < this.snapThresholdX && |
| 1077 | 1104 | Math.abs(y - this.absStartY) < this.snapThresholdY ) { |
| 1078 | 1105 | return this.currentPage; |
| @@ -1332,7 +1359,11 @@ | ||
| 1332 | 1359 | if ( now >= destTime ) { |
| 1333 | 1360 | that.isAnimating = false; |
| 1334 | 1361 | that._translate(destX, destY); |
| 1335 | - that.resetPosition(that.options.bounceTime); | |
| 1362 | + | |
| 1363 | + if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 1364 | + that._execEvent('scrollEnd'); | |
| 1365 | + } | |
| 1366 | + | |
| 1336 | 1367 | return; |
| 1337 | 1368 | } |
| 1338 | 1369 | |
| @@ -1498,6 +1529,10 @@ | ||
| 1498 | 1529 | utils.removeEvent(window, 'MSPointerUp', this); |
| 1499 | 1530 | utils.removeEvent(window, 'mouseup', this); |
| 1500 | 1531 | } |
| 1532 | + | |
| 1533 | + if ( this.options.defaultScrollbars ) { | |
| 1534 | + this.wrapper.parentNode.removeChild(this.wrapper); | |
| 1535 | + } | |
| 1501 | 1536 | }, |
| 1502 | 1537 | |
| 1503 | 1538 | _start: function (e) { |
| @@ -1509,6 +1544,7 @@ | ||
| 1509 | 1544 | this.transitionTime(0); |
| 1510 | 1545 | |
| 1511 | 1546 | this.initiated = true; |
| 1547 | + this.moved = false; | |
| 1512 | 1548 | this.lastPointX = point.pageX; |
| 1513 | 1549 | this.lastPointY = point.pageY; |
| 1514 | 1550 | |
| @@ -1517,6 +1553,8 @@ | ||
| 1517 | 1553 | utils.addEvent(window, 'touchmove', this); |
| 1518 | 1554 | utils.addEvent(window, 'MSPointerMove', this); |
| 1519 | 1555 | utils.addEvent(window, 'mousemove', this); |
| 1556 | + | |
| 1557 | + this.scroller._execEvent('scrollStart'); | |
| 1520 | 1558 | }, |
| 1521 | 1559 | |
| 1522 | 1560 | _move: function (e) { |
| @@ -1525,6 +1563,8 @@ | ||
| 1525 | 1563 | newX, newY, |
| 1526 | 1564 | timestamp = utils.getTime(); |
| 1527 | 1565 | |
| 1566 | + this.moved = true; | |
| 1567 | + | |
| 1528 | 1568 | deltaX = point.pageX - this.lastPointX; |
| 1529 | 1569 | this.lastPointX = point.pageX; |
| 1530 | 1570 | |
| @@ -1553,6 +1593,10 @@ | ||
| 1553 | 1593 | utils.removeEvent(window, 'touchmove', this); |
| 1554 | 1594 | utils.removeEvent(window, 'MSPointerMove', this); |
| 1555 | 1595 | utils.removeEvent(window, 'mousemove', this); |
| 1596 | + | |
| 1597 | + if ( this.moved ) { | |
| 1598 | + this.scroller._execEvent('scrollEnd'); | |
| 1599 | + } | |
| 1556 | 1600 | }, |
| 1557 | 1601 | |
| 1558 | 1602 | transitionTime: function (time) { |
modified dist/iscroll-lite-min.js +2 −2
| @@ -1,2 +1,2 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | -var IScroll=function(t,i,s){function n(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&r.hasPerspective?" translateZ(0)":"",this.options.useTransition=r.hasTransition&&this.options.useTransition,this.options.useTransform=r.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?r.ease[this.options.bounceEasing]||r.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.x=0,this.y=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}var o=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},r=function(){function n(t){return a===!1?!1:""===a?t:a+t.charAt(0).toUpperCase()+t.substr(1)}var o={},r=i.createElement("div").style,a=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();o.getTime=Date.now||function(){return(new Date).getTime()},o.extend=function(t,i){for(var s in i)t[s]=i[s]},o.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},o.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},o.momentum=function(t,i,e,n,o){var r,a,h=t-i,l=s.abs(h)/e,c=6e-4;return r=t+l*l/(2*c)*(0>h?-1:1),a=l/c,n>r?(r=o?n-o/2.5*(l/8):n,h=s.abs(r-t),a=h/l):r>0&&(r=o?o/2.5*(l/8):0,h=s.abs(t)+r,a=h/l),{destination:s.round(r),duration:a}};var h=n("transform");return o.extend(o,{hasTransform:h!==!1,hasPerspective:n("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:n("transition")in r}),o.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),o.extend(o.style={},{transform:h,transitionTimingFunction:n("transitionTimingFunction"),transitionDuration:n("transitionDuration"),transformOrigin:n("transformOrigin")}),o.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},o.addClass=function(t,i){if(!o.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},o.removeClass=function(t,i){if(o.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},o.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},o.extend(o.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),o.extend(o.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),o.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},o.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},o}();return n.prototype={version:"5.0.1",_init:function(){this._initEvents()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(this.enabled&&(!this.initiated||r.eventType[t.type]===this.initiated)){this.options.preventDefault&&!r.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=r.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=r.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,n,o,a=t.touches?t.touches[0]:t,h=a.pageX-this.pointX,l=a.pageY-this.pointY,c=r.getTime();if(this.pointX=a.pageX,this.pointY=a.pageY,this.distX+=h,this.distY+=l,n=s.abs(this.distX),o=s.abs(this.distY),!(c-this.endTime>300&&10>n&&10>o)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=n>o+this.options.directionLockThreshold?"h":o>=n+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;h=0}i=this.x+(this.hasHorizontalScroll?h:0),e=this.y+(this.hasVerticalScroll?l:0),(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+h/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=h>0?-1:0>h?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,n=(t.changedTouches?t.changedTouches[0]:t,r.getTime()-this.startTime),o=s.round(this.x),a=s.round(this.y),h=s.abs(o-this.startX),l=s.abs(a-this.startY),c=0,p="";if(this.scrollTo(o,a),this.isInTransition=0,this.initiated=0,this.endTime=r.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&r.tap(t,this.options.tap),this.options.click&&r.click(t),void 0;if(this._events.flick&&200>n&&100>h&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>n&&(i=this.hasHorizontalScroll?r.momentum(this.x,this.startX,n,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:o,duration:0},e=this.hasVerticalScroll?r.momentum(this.y,this.startY,n,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:a,duration:0},o=i.destination,a=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(o,a);this.currentPage=u,o=u.x,a=u.y,c=this.options.snapSpeed||s.max(s.max(s.min(h,1e3),s.min(h,1e3)),300),p=this.options.bounceEasing}return o!=this.x||a!=this.y?((o>0||o<this.maxScrollX||a>0||a<this.maxScrollY)&&(p=r.ease.quadratic),this.scrollTo(o,a,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh(),t.resetPosition()},this.options.resizePolling)},resetPosition:function(t){if(this.x<=0&&this.x>=this.maxScrollX&&this.y<=0&&this.y>=this.maxScrollY)return!1;var i=this.x,s=this.y;if(t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),this.options.snap){var e=this._nearestSnap(i,s);this.currentPage=e,i=e.x,s=e.y}return this.scrollTo(i,s,t,this.options.bounceEasing),!0},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.maxScrollX>0&&(this.maxScrollX=0),this.maxScrollY>0&&(this.maxScrollY=0),this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.endTime=0,this.wrapperOffset=r.offset(this.wrapper),this._execEvent("refresh")},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||r.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,n,o){if(t=t.nodeType?t:this.scroller.querySelector(t)){var a=r.offset(t);a.left-=this.wrapperOffset.left,a.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),n===!0&&(n=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),a.left-=e||0,a.top-=n||0,a.left=a.left>0?0:a.left<this.maxScrollX?this.maxScrollX:a.left,a.top=a.top>0?0:a.top<this.maxScrollY?this.maxScrollY:a.top,i=s.max(2*s.abs(a.left),2*s.abs(a.top)),this.scrollTo(a.left,a.top,i,o)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[r.style.transitionDuration]=t+"ms"},_transitionTimingFunction:function(t){this.scrollerStyle[r.style.transitionTimingFunction]=t},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[r.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i},_initEvents:function(i){var s=i?r.removeEvent:r.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),r.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),r.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[r.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_animate:function(t,i,s,e){function n(){var u,f,m,d=r.getTime();return d>=p?(a.isAnimating=!1,a._translate(t,i),a.resetPosition(a.options.bounceTime),void 0):(d=(d-c)/s,m=e(d),u=(t-h)*m+h,f=(i-l)*m+l,a._translate(u,f),a.isAnimating&&o(n),void 0)}var a=this,h=this.x,l=this.y,c=r.getTime(),p=c+s;this.isAnimating=!0,n()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t)}}},n.ease=r.ease,n}(window,document,Math); | |
| No newline at the end of the file | ||
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | +var IScroll=function(t,i,s){function n(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&r.hasPerspective?" translateZ(0)":"",this.options.useTransition=r.hasTransition&&this.options.useTransition,this.options.useTransform=r.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?r.ease[this.options.bounceEasing]||r.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}var o=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},r=function(){function n(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var o={},r=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();o.getTime=Date.now||function(){return(new Date).getTime()},o.extend=function(t,i){for(var s in i)t[s]=i[s]},o.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},o.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},o.momentum=function(t,i,e,n,o){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,n>r?(r=o?n-o/2.5*(l/8):n,a=s.abs(r-t),h=a/l):r>0&&(r=o?o/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var a=n("transform");return o.extend(o,{hasTransform:a!==!1,hasPerspective:n("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:n("transition")in r}),o.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),o.extend(o.style={},{transform:a,transitionTimingFunction:n("transitionTimingFunction"),transitionDuration:n("transitionDuration"),transformOrigin:n("transformOrigin")}),o.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},o.addClass=function(t,i){if(!o.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},o.removeClass=function(t,i){if(o.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},o.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},o.extend(o.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),o.extend(o.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),o.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},o.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},o}();return n.prototype={version:"5.0.2",_init:function(){this._initEvents()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(!(1!=r.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&r.eventType[t.type]!==this.initiated)){this.options.preventDefault&&!r.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=r.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=r.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,n,o,h=t.touches?t.touches[0]:t,a=this.hasHorizontalScroll?h.pageX-this.pointX:0,l=this.hasVerticalScroll?h.pageY-this.pointY:0,c=r.getTime();if(this.pointX=h.pageX,this.pointY=h.pageY,this.distX+=a,this.distY+=l,n=s.abs(this.distX),o=s.abs(this.distY),!(c-this.endTime>300&&10>n&&10>o)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=n>o+this.options.directionLockThreshold?"h":o>=n+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;a=0}i=this.x+a,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+a/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=a>0?-1:0>a?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,n=(t.changedTouches?t.changedTouches[0]:t,r.getTime()-this.startTime),o=s.round(this.x),h=s.round(this.y),a=s.abs(o-this.startX),l=s.abs(h-this.startY),c=0,p="";if(this.scrollTo(o,h),this.isInTransition=0,this.initiated=0,this.endTime=r.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&r.tap(t,this.options.tap),this.options.click&&r.click(t),void 0;if(this._events.flick&&200>n&&100>a&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>n&&(i=this.hasHorizontalScroll?r.momentum(this.x,this.startX,n,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:o,duration:0},e=this.hasVerticalScroll?r.momentum(this.y,this.startY,n,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:h,duration:0},o=i.destination,h=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(o,h);this.currentPage=u,o=u.x,h=u.y,c=this.options.snapSpeed||s.max(s.max(s.min(a,1e3),s.min(a,1e3)),300),this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return o!=this.x||h!=this.y?((o>0||o<this.maxScrollX||h>0||h<this.maxScrollY)&&(p=r.ease.quadratic),this.scrollTo(o,h,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh()},this.options.resizePolling)},resetPosition:function(t){var i=this.x,s=this.y;return t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),i==this.x&&s==this.y?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){if(this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.hasHorizontalScroll||(this.maxScrollX=0,this.scrollerWidth=this.wrapperWidth),this.hasVerticalScroll||(this.maxScrollY=0,this.scrollerHeight=this.wrapperHeight),this.endTime=0,this.directionX=0,this.directionY=0,this.wrapperOffset=r.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition(),this.options.snap){var t=this._nearestSnap(this.x,this.y);if(this.x==t.x&&this.y==t.y)return;this.currentPage=t,this.scrollTo(t.x,t.y)}},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||r.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,n,o){if(t=t.nodeType?t:this.scroller.querySelector(t)){var h=r.offset(t);h.left-=this.wrapperOffset.left,h.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),n===!0&&(n=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),h.left-=e||0,h.top-=n||0,h.left=h.left>0?0:h.left<this.maxScrollX?this.maxScrollX:h.left,h.top=h.top>0?0:h.top<this.maxScrollY?this.maxScrollY:h.top,i=void 0===i||null===i||"auto"===i?s.max(2*s.abs(h.left),2*s.abs(h.top)):i,this.scrollTo(h.left,h.top,i,o)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[r.style.transitionDuration]=t+"ms"},_transitionTimingFunction:function(t){this.scrollerStyle[r.style.transitionTimingFunction]=t},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[r.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i},_initEvents:function(i){var s=i?r.removeEvent:r.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),r.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),r.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[r.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_animate:function(t,i,s,e){function n(){var u,f,d,m=r.getTime();return m>=p?(h.isAnimating=!1,h._translate(t,i),h.resetPosition(h.options.bounceTime)||h._execEvent("scrollEnd"),void 0):(m=(m-c)/s,d=e(m),u=(t-a)*d+a,f=(i-l)*d+l,h._translate(u,f),h.isAnimating&&o(n),void 0)}var h=this,a=this.x,l=this.y,c=r.getTime(),p=c+s;this.isAnimating=!0,n()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t)}}},n.ease=r.ease,n}(window,document,Math); | |
| No newline at the end of the file |
modified dist/iscroll-min.js +2 −2
| @@ -1,2 +1,2 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | -var IScroll=function(t,i,s){function o(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeIndicator:!0,snapThreshold:.334,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&a.hasPerspective?" translateZ(0)":"",this.options.useTransition=a.hasTransition&&this.options.useTransition,this.options.useTransform=a.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?a.ease[this.options.bounceEasing]||a.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.x=0,this.y=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function n(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),s||(o.style.pointerEvents="none"),o.appendChild(n),o}function r(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(a.addEvent(this.indicator,"touchstart",this),a.addEvent(this.indicator,"MSPointerDown",this),a.addEvent(this.indicator,"mousedown",this),a.addEvent(t,"touchend",this),a.addEvent(t,"MSPointerUp",this),a.addEvent(t,"mouseup",this))}var h=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},a=function(){function o(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},r=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var s in i)t[s]=i[s]},n.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},n.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},n.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var a=o("transform");return n.extend(n,{hasTransform:a!==!1,hasPerspective:o("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:o("transition")in r}),n.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:a,transitionTimingFunction:o("transitionTimingFunction"),transitionDuration:o("transitionDuration"),transformOrigin:o("transformOrigin")}),n.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},n.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),n.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},n.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},n}();return o.prototype={version:"5.0.1",_init:function(){this._initEvents(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(this.enabled&&(!this.initiated||a.eventType[t.type]===this.initiated)){this.options.preventDefault&&!a.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=a.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=a.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,h=r.pageX-this.pointX,l=r.pageY-this.pointY,c=a.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=h,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;h=0}i=this.x+(this.hasHorizontalScroll?h:0),e=this.y+(this.hasVerticalScroll?l:0),(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+h/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=h>0?-1:0>h?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,a.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),h=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.scrollTo(n,r),this.isInTransition=0,this.initiated=0,this.endTime=a.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&a.tap(t,this.options.tap),this.options.click&&a.click(t),void 0;if(this._events.flick&&200>o&&100>h&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?a.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?a.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(n,r);this.currentPage=u,n=u.x,r=u.y,c=this.options.snapSpeed||s.max(s.max(s.min(h,1e3),s.min(h,1e3)),300),p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=a.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh(),t.resetPosition()},this.options.resizePolling)},resetPosition:function(t){if(this.x<=0&&this.x>=this.maxScrollX&&this.y<=0&&this.y>=this.maxScrollY)return!1;var i=this.x,s=this.y;if(t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),this.options.snap){var e=this._nearestSnap(i,s);this.currentPage=e,i=e.x,s=e.y}return this.scrollTo(i,s,t,this.options.bounceEasing),!0},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.maxScrollX>0&&(this.maxScrollX=0),this.maxScrollY>0&&(this.maxScrollY=0),this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.endTime=0,this.wrapperOffset=a.offset(this.wrapper),this._execEvent("refresh")},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||a.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=a.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=s.max(2*s.abs(r.left),2*s.abs(r.top)),this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[a.style.transitionDuration]=t+"ms",this.indicator1&&this.indicator1.transitionTime(t),this.indicator2&&this.indicator2.transitionTime(t)},_transitionTimingFunction:function(t){this.scrollerStyle[a.style.transitionTimingFunction]=t,this.indicator1&&this.indicator1.transitionTimingFunction(t),this.indicator2&&this.indicator2.transitionTimingFunction(t)},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicator1&&this.indicator1.updatePosition(),this.indicator2&&this.indicator2.updatePosition()},_initEvents:function(i){var s=i?a.removeEvent:a.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),a.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),a.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[a.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_initIndicators:function(){var t,i,s=this.options.interactiveScrollbars;"object"!=typeof this.options.scrollbars,this.options.scrollbars?(this.options.scrollY&&(t={el:n("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenX:!1},this.wrapper.appendChild(t.el)),this.options.scrollX&&(i={el:n("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenY:!1},this.wrapper.appendChild(i.el))):(t=this.options.indicators.length?this.options.indicators[0]:this.options.indicators,i=this.options.indicators[1]&&this.options.indicators[1]),t&&(this.indicator1=new r(this,t)),i&&(this.indicator2=new r(this,i)),this.on("refresh",function(){this.indicator1&&this.indicator1.refresh(),this.indicator2&&this.indicator2.refresh()}),this.on("destroy",function(){this.indicator1&&this.indicator1.destroy(),this.indicator2&&this.indicator2.destroy()})},_initWheel:function(){a.addEvent(this.wrapper,"mousewheel",this),a.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){a.removeEvent(this.wrapper,"mousewheel",this),a.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){var i,s,e,o,n=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){n._execEvent("scrollEnd")},400),t.preventDefault(),"wheelDeltaX"in t)i=t.wheelDeltaX/120,s=t.wheelDeltaY/120;else if("wheelDelta"in t)i=s=t.wheelDelta/120;else{if(!("detail"in t))return;i=s=-t.detail/3}i*=10,s*=10,this.hasVerticalScroll||(i=s),e=this.x+(this.hasHorizontalScroll?i*this.options.invertWheelDirection:0),o=this.y+(this.hasVerticalScroll?s*this.options.invertWheelDirection:0),e>0?e=0:e<this.maxScrollX&&(e=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(e,o,0)},_initSnap:function(){this.pages=[],this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},a++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),0===this.options.snapThreshold%1?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){var e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[0].length?i=this.pages[0].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},next:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s++,s>=this.pages.length&&this.hasVericalScroll&&(s=0,e++),this.goToPage(s,e,t,i)},prev:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s--,0>s&&this.hasVericalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in s)this.options.keyBindings[i]=this.options.keyBindings[i]||s[i];a.addEvent(t,"keydown",this),this.on("destroy",function(){a.removeEvent(t,"keydown",this)})},_key:function(t){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=a.getTime(),h=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-h?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0}return e?(this.goToPage(o,n),void 0):(o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r,void 0)},_animate:function(t,i,s,e){function o(){var u,d,m,f=a.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime),void 0):(f=(f-c)/s,m=e(f),u=(t-r)*m+r,d=(i-l)*m+l,n._translate(u,d),n.isAnimating&&h(o),void 0)}var n=this,r=this.x,l=this.y,c=a.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t)}}},r.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(a.removeEvent(this.indicator,"touchstart",this),a.removeEvent(this.indicator,"MSPointerDown",this),a.removeEvent(this.indicator,"mousedown",this),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),a.removeEvent(t,"touchend",this),a.removeEvent(t,"MSPointerUp",this),a.removeEvent(t,"mouseup",this))},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(0),this.initiated=!0,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=a.getTime(),a.addEvent(t,"touchmove",this),a.addEvent(t,"MSPointerMove",this),a.addEvent(t,"mousemove",this)},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t;a.getTime(),i=n.pageX-this.lastPointX,this.lastPointX=n.pageX,s=n.pageY-this.lastPointY,this.lastPointY=n.pageY,e=this.x+i,o=this.y+s,this._pos(e,o),t.preventDefault(),t.stopPropagation()},_end:function(i){this.initiated&&(this.initiated=!1,i.preventDefault(),i.stopPropagation(),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this))},transitionTime:function(t){t=t||0,this.indicatorStyle[a.style.transitionDuration]=t+"ms"},transitionTimingFunction:function(t){this.indicatorStyle[a.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(0),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(a.addClass(this.wrapper,"iScrollBothScrollbars"),a.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(a.removeClass(this.wrapper,"iScrollBothScrollbars"),a.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px")),this.wrapper.offsetHeight,this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.round(this.wrapperWidth*this.wrapperWidth/this.scroller.scrollerWidth),8),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=s.max(s.round(this.wrapperHeight*this.wrapperHeight/this.scroller.scrollerHeight),8),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=s.round(this.sizeRatioX*this.scroller.x)||0,i=s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY)),this.x=t,this.y=i,this.scroller.options.useTransform?this.indicatorStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),this.scroller.scrollTo(s.round(t/this.sizeRatioX),s.round(i/this.sizeRatioY))}},o.ease=a.ease,o}(window,document,Math); | |
| No newline at the end of the file | ||
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | +var IScroll=function(t,i,s){function o(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeIndicator:!0,mouseWheelSpeed:20,snapThreshold:.334,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&a.hasPerspective?" translateZ(0)":"",this.options.useTransition=a.hasTransition&&this.options.useTransition,this.options.useTransform=a.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?a.ease[this.options.bounceEasing]||a.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function n(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),s||(o.style.pointerEvents="none"),o.appendChild(n),o}function r(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(a.addEvent(this.indicator,"touchstart",this),a.addEvent(this.indicator,"MSPointerDown",this),a.addEvent(this.indicator,"mousedown",this),a.addEvent(t,"touchend",this),a.addEvent(t,"MSPointerUp",this),a.addEvent(t,"mouseup",this))}var h=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},a=function(){function o(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},r=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var s in i)t[s]=i[s]},n.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},n.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},n.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var a=o("transform");return n.extend(n,{hasTransform:a!==!1,hasPerspective:o("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:o("transition")in r}),n.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:a,transitionTimingFunction:o("transitionTimingFunction"),transitionDuration:o("transitionDuration"),transformOrigin:o("transformOrigin")}),n.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},n.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),n.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},n.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},n}();return o.prototype={version:"5.0.2",_init:function(){this._initEvents(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(!(1!=a.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&a.eventType[t.type]!==this.initiated)){this.options.preventDefault&&!a.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=a.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=a.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,h=this.hasHorizontalScroll?r.pageX-this.pointX:0,l=this.hasVerticalScroll?r.pageY-this.pointY:0,c=a.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=h,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;h=0}i=this.x+h,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+h/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=h>0?-1:0>h?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,a.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),h=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.scrollTo(n,r),this.isInTransition=0,this.initiated=0,this.endTime=a.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&a.tap(t,this.options.tap),this.options.click&&a.click(t),void 0;if(this._events.flick&&200>o&&100>h&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?a.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?a.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(n,r);this.currentPage=u,n=u.x,r=u.y,c=this.options.snapSpeed||s.max(s.max(s.min(h,1e3),s.min(h,1e3)),300),this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=a.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh()},this.options.resizePolling)},resetPosition:function(t){var i=this.x,s=this.y;return t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),i==this.x&&s==this.y?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){if(this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.hasHorizontalScroll||(this.maxScrollX=0,this.scrollerWidth=this.wrapperWidth),this.hasVerticalScroll||(this.maxScrollY=0,this.scrollerHeight=this.wrapperHeight),this.endTime=0,this.directionX=0,this.directionY=0,this.wrapperOffset=a.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition(),this.options.snap){var t=this._nearestSnap(this.x,this.y);if(this.x==t.x&&this.y==t.y)return;this.currentPage=t,this.scrollTo(t.x,t.y)}},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||a.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=a.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=void 0===i||null===i||"auto"===i?s.max(2*s.abs(r.left),2*s.abs(r.top)):i,this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[a.style.transitionDuration]=t+"ms",this.indicator1&&this.indicator1.transitionTime(t),this.indicator2&&this.indicator2.transitionTime(t)},_transitionTimingFunction:function(t){this.scrollerStyle[a.style.transitionTimingFunction]=t,this.indicator1&&this.indicator1.transitionTimingFunction(t),this.indicator2&&this.indicator2.transitionTimingFunction(t)},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicator1&&this.indicator1.updatePosition(),this.indicator2&&this.indicator2.updatePosition()},_initEvents:function(i){var s=i?a.removeEvent:a.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),a.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),a.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[a.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_initIndicators:function(){var t,i,s=this.options.interactiveScrollbars;"object"!=typeof this.options.scrollbars,this.options.scrollbars?(this.options.scrollY&&(t={el:n("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenX:!1},this.wrapper.appendChild(t.el)),this.options.scrollX&&(i={el:n("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenY:!1},this.wrapper.appendChild(i.el))):(t=this.options.indicators.length?this.options.indicators[0]:this.options.indicators,i=this.options.indicators[1]&&this.options.indicators[1]),t&&(this.indicator1=new r(this,t)),i&&(this.indicator2=new r(this,i)),this.on("refresh",function(){this.indicator1&&this.indicator1.refresh(),this.indicator2&&this.indicator2.refresh()}),this.on("destroy",function(){this.indicator1&&(this.indicator1.destroy(),this.indicator1=null),this.indicator2&&(this.indicator2.destroy(),this.indicator2=null)})},_initWheel:function(){a.addEvent(this.wrapper,"mousewheel",this),a.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){a.removeEvent(this.wrapper,"mousewheel",this),a.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){var i,s,e,o,n=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){n._execEvent("scrollEnd")},400),t.preventDefault(),"wheelDeltaX"in t)i=t.wheelDeltaX/120,s=t.wheelDeltaY/120;else if("wheelDelta"in t)i=s=t.wheelDelta/120;else{if(!("detail"in t))return;i=s=-t.detail/3}i*=this.options.mouseWheelSpeed,s*=this.options.mouseWheelSpeed,this.hasVerticalScroll||(i=s),e=this.x+(this.hasHorizontalScroll?i*this.options.invertWheelDirection:0),o=this.y+(this.hasVerticalScroll?s*this.options.invertWheelDirection:0),e>0?e=0:e<this.maxScrollX&&(e=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(e,o,0)},_initSnap:function(){this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},l>this.maxScrollX&&a++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),0===this.options.snapThreshold%1?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){var e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[0].length?i=this.pages[0].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},next:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s++,s>=this.pages.length&&this.hasVericalScroll&&(s=0,e++),this.goToPage(s,e,t,i)},prev:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s--,0>s&&this.hasVericalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in s)this.options.keyBindings[i]=this.options.keyBindings[i]||s[i];a.addEvent(t,"keydown",this),this.on("destroy",function(){a.removeEvent(t,"keydown",this)})},_key:function(t){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=a.getTime(),h=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-h?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0}return e?(this.goToPage(o,n),void 0):(o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r,void 0)},_animate:function(t,i,s,e){function o(){var u,d,m,f=a.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"),void 0):(f=(f-c)/s,m=e(f),u=(t-r)*m+r,d=(i-l)*m+l,n._translate(u,d),n.isAnimating&&h(o),void 0)}var n=this,r=this.x,l=this.y,c=a.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t)}}},r.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(a.removeEvent(this.indicator,"touchstart",this),a.removeEvent(this.indicator,"MSPointerDown",this),a.removeEvent(this.indicator,"mousedown",this),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),a.removeEvent(t,"touchend",this),a.removeEvent(t,"MSPointerUp",this),a.removeEvent(t,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(0),this.initiated=!0,this.moved=!1,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=a.getTime(),a.addEvent(t,"touchmove",this),a.addEvent(t,"MSPointerMove",this),a.addEvent(t,"mousemove",this),this.scroller._execEvent("scrollStart")},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t;a.getTime(),this.moved=!0,i=n.pageX-this.lastPointX,this.lastPointX=n.pageX,s=n.pageY-this.lastPointY,this.lastPointY=n.pageY,e=this.x+i,o=this.y+s,this._pos(e,o),t.preventDefault(),t.stopPropagation()},_end:function(i){this.initiated&&(this.initiated=!1,i.preventDefault(),i.stopPropagation(),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),this.moved&&this.scroller._execEvent("scrollEnd"))},transitionTime:function(t){t=t||0,this.indicatorStyle[a.style.transitionDuration]=t+"ms"},transitionTimingFunction:function(t){this.indicatorStyle[a.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(0),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(a.addClass(this.wrapper,"iScrollBothScrollbars"),a.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(a.removeClass(this.wrapper,"iScrollBothScrollbars"),a.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px")),this.wrapper.offsetHeight,this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.round(this.wrapperWidth*this.wrapperWidth/this.scroller.scrollerWidth),8),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=s.max(s.round(this.wrapperHeight*this.wrapperHeight/this.scroller.scrollerHeight),8),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=s.round(this.sizeRatioX*this.scroller.x)||0,i=s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY)),this.x=t,this.y=i,this.scroller.options.useTransform?this.indicatorStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),this.scroller.scrollTo(s.round(t/this.sizeRatioX),s.round(i/this.sizeRatioY))}},o.ease=a.ease,o}(window,document,Math); | |
| No newline at the end of the file |
modified dist/iscroll-probe-min.js +2 −2
| @@ -1,2 +1,2 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | -var IScroll=function(t,i,s){function o(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeIndicator:!0,snapThreshold:.334,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&a.hasPerspective?" translateZ(0)":"",this.options.useTransition=a.hasTransition&&this.options.useTransition,this.options.useTransform=a.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?a.ease[this.options.bounceEasing]||a.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,3==this.options.probeType&&(this.options.useTransition=!1),this.x=0,this.y=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function n(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),s||(o.style.pointerEvents="none"),o.appendChild(n),o}function r(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(a.addEvent(this.indicator,"touchstart",this),a.addEvent(this.indicator,"MSPointerDown",this),a.addEvent(this.indicator,"mousedown",this),a.addEvent(t,"touchend",this),a.addEvent(t,"MSPointerUp",this),a.addEvent(t,"mouseup",this))}var h=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},a=function(){function o(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},r=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var s in i)t[s]=i[s]},n.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},n.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},n.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var a=o("transform");return n.extend(n,{hasTransform:a!==!1,hasPerspective:o("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:o("transition")in r}),n.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:a,transitionTimingFunction:o("transitionTimingFunction"),transitionDuration:o("transitionDuration"),transformOrigin:o("transformOrigin")}),n.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},n.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),n.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},n.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},n}();return o.prototype={version:"5.0.1",_init:function(){this._initEvents(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(this.enabled&&(!this.initiated||a.eventType[t.type]===this.initiated)){this.options.preventDefault&&!a.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=a.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=a.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,h=r.pageX-this.pointX,l=r.pageY-this.pointY,c=a.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=h,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;h=0}i=this.x+(this.hasHorizontalScroll?h:0),e=this.y+(this.hasVerticalScroll?l:0),(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+h/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=h>0?-1:0>h?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y,1==this.options.probeType&&this._execEvent("scroll")),this.options.probeType>1&&this._execEvent("scroll")}}},_end:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,a.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),h=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.scrollTo(n,r),this.isInTransition=0,this.initiated=0,this.endTime=a.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&a.tap(t,this.options.tap),this.options.click&&a.click(t),void 0;if(this._events.flick&&200>o&&100>h&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?a.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?a.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(n,r);this.currentPage=u,n=u.x,r=u.y,c=this.options.snapSpeed||s.max(s.max(s.min(h,1e3),s.min(h,1e3)),300),p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=a.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh(),t.resetPosition()},this.options.resizePolling)},resetPosition:function(t){if(this.x<=0&&this.x>=this.maxScrollX&&this.y<=0&&this.y>=this.maxScrollY)return!1;var i=this.x,s=this.y;if(t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),this.options.snap){var e=this._nearestSnap(i,s);this.currentPage=e,i=e.x,s=e.y}return this.scrollTo(i,s,t,this.options.bounceEasing),!0},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.maxScrollX>0&&(this.maxScrollX=0),this.maxScrollY>0&&(this.maxScrollY=0),this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.endTime=0,this.wrapperOffset=a.offset(this.wrapper),this._execEvent("refresh")},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||a.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=a.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=s.max(2*s.abs(r.left),2*s.abs(r.top)),this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[a.style.transitionDuration]=t+"ms",this.indicator1&&this.indicator1.transitionTime(t),this.indicator2&&this.indicator2.transitionTime(t)},_transitionTimingFunction:function(t){this.scrollerStyle[a.style.transitionTimingFunction]=t,this.indicator1&&this.indicator1.transitionTimingFunction(t),this.indicator2&&this.indicator2.transitionTimingFunction(t)},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicator1&&this.indicator1.updatePosition(),this.indicator2&&this.indicator2.updatePosition()},_initEvents:function(i){var s=i?a.removeEvent:a.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),a.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),a.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[a.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_initIndicators:function(){var t,i,s=this.options.interactiveScrollbars;"object"!=typeof this.options.scrollbars,this.options.scrollbars?(this.options.scrollY&&(t={el:n("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenX:!1},this.wrapper.appendChild(t.el)),this.options.scrollX&&(i={el:n("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenY:!1},this.wrapper.appendChild(i.el))):(t=this.options.indicators.length?this.options.indicators[0]:this.options.indicators,i=this.options.indicators[1]&&this.options.indicators[1]),t&&(this.indicator1=new r(this,t)),i&&(this.indicator2=new r(this,i)),this.on("refresh",function(){this.indicator1&&this.indicator1.refresh(),this.indicator2&&this.indicator2.refresh()}),this.on("destroy",function(){this.indicator1&&this.indicator1.destroy(),this.indicator2&&this.indicator2.destroy()})},_initWheel:function(){a.addEvent(this.wrapper,"mousewheel",this),a.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){a.removeEvent(this.wrapper,"mousewheel",this),a.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){var i,s,e,o,n=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){n._execEvent("scrollEnd")},400),t.preventDefault(),"wheelDeltaX"in t)i=t.wheelDeltaX/120,s=t.wheelDeltaY/120;else if("wheelDelta"in t)i=s=t.wheelDelta/120;else{if(!("detail"in t))return;i=s=-t.detail/3}i*=10,s*=10,this.hasVerticalScroll||(i=s),e=this.x+(this.hasHorizontalScroll?i*this.options.invertWheelDirection:0),o=this.y+(this.hasVerticalScroll?s*this.options.invertWheelDirection:0),e>0?e=0:e<this.maxScrollX&&(e=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(e,o,0),this.options.probeType>1&&this._execEvent("scroll")},_initSnap:function(){this.pages=[],this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},a++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),0===this.options.snapThreshold%1?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){var e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[0].length?i=this.pages[0].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},next:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s++,s>=this.pages.length&&this.hasVericalScroll&&(s=0,e++),this.goToPage(s,e,t,i)},prev:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s--,0>s&&this.hasVericalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in s)this.options.keyBindings[i]=this.options.keyBindings[i]||s[i];a.addEvent(t,"keydown",this),this.on("destroy",function(){a.removeEvent(t,"keydown",this)})},_key:function(t){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=a.getTime(),h=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-h?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0}return e?(this.goToPage(o,n),void 0):(o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r,void 0)},_animate:function(t,i,s,e){function o(){var u,d,m,f=a.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"),void 0):(f=(f-c)/s,m=e(f),u=(t-r)*m+r,d=(i-l)*m+l,n._translate(u,d),n.isAnimating&&h(o),3==n.options.probeType&&n._execEvent("scroll"),void 0)}var n=this,r=this.x,l=this.y,c=a.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t)}}},r.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(a.removeEvent(this.indicator,"touchstart",this),a.removeEvent(this.indicator,"MSPointerDown",this),a.removeEvent(this.indicator,"mousedown",this),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),a.removeEvent(t,"touchend",this),a.removeEvent(t,"MSPointerUp",this),a.removeEvent(t,"mouseup",this))},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(0),this.initiated=!0,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=a.getTime(),a.addEvent(t,"touchmove",this),a.addEvent(t,"MSPointerMove",this),a.addEvent(t,"mousemove",this)},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t;a.getTime(),i=n.pageX-this.lastPointX,this.lastPointX=n.pageX,s=n.pageY-this.lastPointY,this.lastPointY=n.pageY,e=this.x+i,o=this.y+s,this._pos(e,o),t.preventDefault(),t.stopPropagation()},_end:function(i){this.initiated&&(this.initiated=!1,i.preventDefault(),i.stopPropagation(),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this))},transitionTime:function(t){t=t||0,this.indicatorStyle[a.style.transitionDuration]=t+"ms"},transitionTimingFunction:function(t){this.indicatorStyle[a.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(0),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(a.addClass(this.wrapper,"iScrollBothScrollbars"),a.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(a.removeClass(this.wrapper,"iScrollBothScrollbars"),a.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px")),this.wrapper.offsetHeight,this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.round(this.wrapperWidth*this.wrapperWidth/this.scroller.scrollerWidth),8),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=s.max(s.round(this.wrapperHeight*this.wrapperHeight/this.scroller.scrollerHeight),8),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=s.round(this.sizeRatioX*this.scroller.x)||0,i=s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY)),this.x=t,this.y=i,this.scroller.options.useTransform?this.indicatorStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),this.scroller.scrollTo(s.round(t/this.sizeRatioX),s.round(i/this.sizeRatioY))}},o.ease=a.ease,o}(window,document,Math); | |
| No newline at the end of the file | ||
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | +var IScroll=function(t,i,s){function o(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeIndicator:!0,mouseWheelSpeed:20,snapThreshold:.334,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&a.hasPerspective?" translateZ(0)":"",this.options.useTransition=a.hasTransition&&this.options.useTransition,this.options.useTransform=a.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?a.ease[this.options.bounceEasing]||a.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,3==this.options.probeType&&(this.options.useTransition=!1),this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function n(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),s||(o.style.pointerEvents="none"),o.appendChild(n),o}function r(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(a.addEvent(this.indicator,"touchstart",this),a.addEvent(this.indicator,"MSPointerDown",this),a.addEvent(this.indicator,"mousedown",this),a.addEvent(t,"touchend",this),a.addEvent(t,"MSPointerUp",this),a.addEvent(t,"mouseup",this))}var h=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},a=function(){function o(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},r=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var s in i)t[s]=i[s]},n.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},n.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},n.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var a=o("transform");return n.extend(n,{hasTransform:a!==!1,hasPerspective:o("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:o("transition")in r}),n.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:a,transitionTimingFunction:o("transitionTimingFunction"),transitionDuration:o("transitionDuration"),transformOrigin:o("transformOrigin")}),n.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},n.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),n.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},n.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},n}();return o.prototype={version:"5.0.2",_init:function(){this._initEvents(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(!(1!=a.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&a.eventType[t.type]!==this.initiated)){this.options.preventDefault&&!a.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=a.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=a.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,h=this.hasHorizontalScroll?r.pageX-this.pointX:0,l=this.hasVerticalScroll?r.pageY-this.pointY:0,c=a.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=h,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;h=0}i=this.x+h,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+h/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=h>0?-1:0>h?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y,1==this.options.probeType&&this._execEvent("scroll")),this.options.probeType>1&&this._execEvent("scroll")}}},_end:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,a.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),h=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.scrollTo(n,r),this.isInTransition=0,this.initiated=0,this.endTime=a.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&a.tap(t,this.options.tap),this.options.click&&a.click(t),void 0;if(this._events.flick&&200>o&&100>h&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?a.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?a.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var d=this._nearestSnap(n,r);this.currentPage=d,n=d.x,r=d.y,c=this.options.snapSpeed||s.max(s.max(s.min(h,1e3),s.min(h,1e3)),300),this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=a.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh()},this.options.resizePolling)},resetPosition:function(t){var i=this.x,s=this.y;return t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),i==this.x&&s==this.y?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){if(this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.hasHorizontalScroll||(this.maxScrollX=0,this.scrollerWidth=this.wrapperWidth),this.hasVerticalScroll||(this.maxScrollY=0,this.scrollerHeight=this.wrapperHeight),this.endTime=0,this.directionX=0,this.directionY=0,this.wrapperOffset=a.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition(),this.options.snap){var t=this._nearestSnap(this.x,this.y);if(this.x==t.x&&this.y==t.y)return;this.currentPage=t,this.scrollTo(t.x,t.y)}},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||a.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=a.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=void 0===i||null===i||"auto"===i?s.max(2*s.abs(r.left),2*s.abs(r.top)):i,this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[a.style.transitionDuration]=t+"ms",this.indicator1&&this.indicator1.transitionTime(t),this.indicator2&&this.indicator2.transitionTime(t)},_transitionTimingFunction:function(t){this.scrollerStyle[a.style.transitionTimingFunction]=t,this.indicator1&&this.indicator1.transitionTimingFunction(t),this.indicator2&&this.indicator2.transitionTimingFunction(t)},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicator1&&this.indicator1.updatePosition(),this.indicator2&&this.indicator2.updatePosition()},_initEvents:function(i){var s=i?a.removeEvent:a.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),a.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),a.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[a.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_initIndicators:function(){var t,i,s=this.options.interactiveScrollbars;"object"!=typeof this.options.scrollbars,this.options.scrollbars?(this.options.scrollY&&(t={el:n("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenX:!1},this.wrapper.appendChild(t.el)),this.options.scrollX&&(i={el:n("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenY:!1},this.wrapper.appendChild(i.el))):(t=this.options.indicators.length?this.options.indicators[0]:this.options.indicators,i=this.options.indicators[1]&&this.options.indicators[1]),t&&(this.indicator1=new r(this,t)),i&&(this.indicator2=new r(this,i)),this.on("refresh",function(){this.indicator1&&this.indicator1.refresh(),this.indicator2&&this.indicator2.refresh()}),this.on("destroy",function(){this.indicator1&&(this.indicator1.destroy(),this.indicator1=null),this.indicator2&&(this.indicator2.destroy(),this.indicator2=null)})},_initWheel:function(){a.addEvent(this.wrapper,"mousewheel",this),a.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){a.removeEvent(this.wrapper,"mousewheel",this),a.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){var i,s,e,o,n=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){n._execEvent("scrollEnd")},400),t.preventDefault(),"wheelDeltaX"in t)i=t.wheelDeltaX/120,s=t.wheelDeltaY/120;else if("wheelDelta"in t)i=s=t.wheelDelta/120;else{if(!("detail"in t))return;i=s=-t.detail/3}i*=this.options.mouseWheelSpeed,s*=this.options.mouseWheelSpeed,this.hasVerticalScroll||(i=s),e=this.x+(this.hasHorizontalScroll?i*this.options.invertWheelDirection:0),o=this.y+(this.hasVerticalScroll?s*this.options.invertWheelDirection:0),e>0?e=0:e<this.maxScrollX&&(e=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(e,o,0),this.options.probeType>1&&this._execEvent("scroll")},_initSnap:function(){this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},l>this.maxScrollX&&a++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),0===this.options.snapThreshold%1?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){var e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[0].length?i=this.pages[0].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},next:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s++,s>=this.pages.length&&this.hasVericalScroll&&(s=0,e++),this.goToPage(s,e,t,i)},prev:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s--,0>s&&this.hasVericalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in s)this.options.keyBindings[i]=this.options.keyBindings[i]||s[i];a.addEvent(t,"keydown",this),this.on("destroy",function(){a.removeEvent(t,"keydown",this)})},_key:function(t){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=a.getTime(),h=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-h?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0}return e?(this.goToPage(o,n),void 0):(o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r,void 0)},_animate:function(t,i,s,e){function o(){var d,u,m,f=a.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"),void 0):(f=(f-c)/s,m=e(f),d=(t-r)*m+r,u=(i-l)*m+l,n._translate(d,u),n.isAnimating&&h(o),3==n.options.probeType&&n._execEvent("scroll"),void 0)}var n=this,r=this.x,l=this.y,c=a.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t)}}},r.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(a.removeEvent(this.indicator,"touchstart",this),a.removeEvent(this.indicator,"MSPointerDown",this),a.removeEvent(this.indicator,"mousedown",this),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),a.removeEvent(t,"touchend",this),a.removeEvent(t,"MSPointerUp",this),a.removeEvent(t,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(0),this.initiated=!0,this.moved=!1,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=a.getTime(),a.addEvent(t,"touchmove",this),a.addEvent(t,"MSPointerMove",this),a.addEvent(t,"mousemove",this),this.scroller._execEvent("scrollStart")},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t;a.getTime(),this.moved=!0,i=n.pageX-this.lastPointX,this.lastPointX=n.pageX,s=n.pageY-this.lastPointY,this.lastPointY=n.pageY,e=this.x+i,o=this.y+s,this._pos(e,o),t.preventDefault(),t.stopPropagation()},_end:function(i){this.initiated&&(this.initiated=!1,i.preventDefault(),i.stopPropagation(),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),this.moved&&this.scroller._execEvent("scrollEnd"))},transitionTime:function(t){t=t||0,this.indicatorStyle[a.style.transitionDuration]=t+"ms"},transitionTimingFunction:function(t){this.indicatorStyle[a.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(0),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(a.addClass(this.wrapper,"iScrollBothScrollbars"),a.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(a.removeClass(this.wrapper,"iScrollBothScrollbars"),a.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px")),this.wrapper.offsetHeight,this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.round(this.wrapperWidth*this.wrapperWidth/this.scroller.scrollerWidth),8),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=s.max(s.round(this.wrapperHeight*this.wrapperHeight/this.scroller.scrollerHeight),8),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=s.round(this.sizeRatioX*this.scroller.x)||0,i=s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY)),this.x=t,this.y=i,this.scroller.options.useTransform?this.indicatorStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),this.scroller.scrollTo(s.round(t/this.sizeRatioX),s.round(i/this.sizeRatioY))}},o.ease=a.ease,o}(window,document,Math); | |
| No newline at the end of the file |
modified dist/iscroll-zoom-min.js +2 −2
| @@ -1,2 +1,2 @@ | ||
| 1 | -/*! iScroll v5.0.1 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | -var IScroll=function(t,i,s){function o(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={zoomMin:1,zoomMax:4,resizeIndicator:!0,snapThreshold:.334,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&a.hasPerspective?" translateZ(0)":"",this.options.useTransition=a.hasTransition&&this.options.useTransition,this.options.useTransform=a.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?a.ease[this.options.bounceEasing]||a.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.x=0,this.y=0,this._events={},this.scale=1,this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function n(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),s||(o.style.pointerEvents="none"),o.appendChild(n),o}function r(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(a.addEvent(this.indicator,"touchstart",this),a.addEvent(this.indicator,"MSPointerDown",this),a.addEvent(this.indicator,"mousedown",this),a.addEvent(t,"touchend",this),a.addEvent(t,"MSPointerUp",this),a.addEvent(t,"mouseup",this))}var h=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},a=function(){function o(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},r=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var s in i)t[s]=i[s]},n.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},n.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},n.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var a=o("transform");return n.extend(n,{hasTransform:a!==!1,hasPerspective:o("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:o("transition")in r}),n.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:a,transitionTimingFunction:o("transitionTimingFunction"),transitionDuration:o("transitionDuration"),transformOrigin:o("transformOrigin")}),n.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},n.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),n.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},n.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},n}();return o.prototype={version:"5.0.1",_init:function(){this._initEvents(),this.options.zoom&&this._initZoom(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(this.enabled&&(!this.initiated||a.eventType[t.type]===this.initiated)){this.options.preventDefault&&!a.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=a.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=a.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,h=r.pageX-this.pointX,l=r.pageY-this.pointY,c=a.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=h,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;h=0}i=this.x+(this.hasHorizontalScroll?h:0),e=this.y+(this.hasVerticalScroll?l:0),(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+h/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=h>0?-1:0>h?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,a.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),h=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.scrollTo(n,r),this.isInTransition=0,this.initiated=0,this.endTime=a.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&a.tap(t,this.options.tap),this.options.click&&a.click(t),void 0;if(this._events.flick&&200>o&&100>h&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?a.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?a.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(n,r);this.currentPage=u,n=u.x,r=u.y,c=this.options.snapSpeed||s.max(s.max(s.min(h,1e3),s.min(h,1e3)),300),p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=a.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh(),t.resetPosition()},this.options.resizePolling)},resetPosition:function(t){if(this.x<=0&&this.x>=this.maxScrollX&&this.y<=0&&this.y>=this.maxScrollY)return!1;var i=this.x,s=this.y;if(t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),this.options.snap){var e=this._nearestSnap(i,s);this.currentPage=e,i=e.x,s=e.y}return this.scrollTo(i,s,t,this.options.bounceEasing),!0},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=s.round(this.scroller.offsetWidth*this.scale),this.scrollerHeight=s.round(this.scroller.offsetHeight*this.scale),this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.maxScrollX>0&&(this.maxScrollX=0),this.maxScrollY>0&&(this.maxScrollY=0),this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.endTime=0,this.wrapperOffset=a.offset(this.wrapper),this._execEvent("refresh")},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||a.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=a.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=s.max(2*s.abs(r.left),2*s.abs(r.top)),this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[a.style.transitionDuration]=t+"ms",this.indicator1&&this.indicator1.transitionTime(t),this.indicator2&&this.indicator2.transitionTime(t)},_transitionTimingFunction:function(t){this.scrollerStyle[a.style.transitionTimingFunction]=t,this.indicator1&&this.indicator1.transitionTimingFunction(t),this.indicator2&&this.indicator2.transitionTimingFunction(t)},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[a.style.transform]="translate("+t+"px,"+i+"px) scale("+this.scale+") "+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicator1&&this.indicator1.updatePosition(),this.indicator2&&this.indicator2.updatePosition()},_initEvents:function(i){var s=i?a.removeEvent:a.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),a.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),a.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[a.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_initIndicators:function(){var t,i,s=this.options.interactiveScrollbars;"object"!=typeof this.options.scrollbars,this.options.scrollbars?(this.options.scrollY&&(t={el:n("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenX:!1},this.wrapper.appendChild(t.el)),this.options.scrollX&&(i={el:n("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenY:!1},this.wrapper.appendChild(i.el))):(t=this.options.indicators.length?this.options.indicators[0]:this.options.indicators,i=this.options.indicators[1]&&this.options.indicators[1]),t&&(this.indicator1=new r(this,t)),i&&(this.indicator2=new r(this,i)),this.on("refresh",function(){this.indicator1&&this.indicator1.refresh(),this.indicator2&&this.indicator2.refresh()}),this.on("destroy",function(){this.indicator1&&this.indicator1.destroy(),this.indicator2&&this.indicator2.destroy()})},_initZoom:function(){this.scrollerStyle[a.style.transformOrigin]="0 0"},_zoomStart:function(t){var i=s.abs(t.touches[0].pageX-t.touches[1].pageX),e=s.abs(t.touches[0].pageY-t.touches[1].pageY);this.touchesDistanceStart=s.sqrt(i*i+e*e),this.startScale=this.scale,this.originX=s.abs(t.touches[0].pageX+t.touches[1].pageX)/2+this.wrapperOffset.left-this.x,this.originY=s.abs(t.touches[0].pageY+t.touches[1].pageY)/2+this.wrapperOffset.top-this.y,this._execEvent("zoomStart")},_zoom:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n=s.abs(t.touches[0].pageX-t.touches[1].pageX),r=s.abs(t.touches[0].pageY-t.touches[1].pageY),h=s.sqrt(n*n+r*r),l=1/this.touchesDistanceStart*h*this.startScale;this.scaled=!0,l<this.options.zoomMin?l=.5*this.options.zoomMin*s.pow(2,l/this.options.zoomMin):l>this.options.zoomMax&&(l=2*this.options.zoomMax*s.pow(.5,this.options.zoomMax/l)),i=l/this.startScale,e=this.originX-this.originX*i+this.startX,o=this.originY-this.originY*i+this.startY,this.scale=l,this.scrollTo(e,o,0)}},_zoomEnd:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,s,e;this.isInTransition=0,this.initiated=0,this.scale>this.options.zoomMax?this.scale=this.options.zoomMax:this.scale<this.options.zoomMin&&(this.scale=this.options.zoomMin),this.refresh(),e=this.scale/this.startScale,i=this.originX-this.originX*e+this.startX,s=this.originY-this.originY*e+this.startY,i>0?i=0:i<this.maxScrollX&&(i=this.maxScrollX),s>0?s=0:s<this.maxScrollY&&(s=this.maxScrollY),(this.x!=i||this.y!=s)&&this.scrollTo(i,s,this.options.bounceTime),this.scaled=!1,this._execEvent("zoomEnd")}},zoom:function(t,i,s,e){if(t<this.options.zoomMin?t=this.options.zoomMin:t>this.options.zoomMax&&(t=this.options.zoomMax),t!=this.scale){var o=t/this.scale;i=void 0===i?this.wrapperWidth/2:i,s=void 0===s?this.wrapperHeight/2:s,e=void 0===e?300:e,i=i+this.wrapperOffset.left-this.x,s=s+this.wrapperOffset.top-this.y,i=i-i*o+this.x,s=s-s*o+this.y,this.scale=t,this.refresh(),i>0?i=0:i<this.maxScrollX&&(i=this.maxScrollX),s>0?s=0:s<this.maxScrollY&&(s=this.maxScrollY),this.scrollTo(i,s,e)}},_wheelZoom:function(t){var i,e;if("wheelDeltaX"in t)i=t.wheelDeltaY/s.abs(t.wheelDeltaY);else if("wheelDelta"in t)i=t.wheelDelta/s.abs(t.wheelDelta);else{if(!("detail"in t))return;i=-t.detail/s.abs(t.wheelDelta)}e=this.scale+i/5,this.zoom(e,t.pageX,t.pageY,0)},_initWheel:function(){a.addEvent(this.wrapper,"mousewheel",this),a.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){a.removeEvent(this.wrapper,"mousewheel",this),a.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){var i,s,e,o,n=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){n._execEvent("scrollEnd")},400),t.preventDefault(),"wheelDeltaX"in t)i=t.wheelDeltaX/120,s=t.wheelDeltaY/120;else if("wheelDelta"in t)i=s=t.wheelDelta/120;else{if(!("detail"in t))return;i=s=-t.detail/3}i*=10,s*=10,this.hasVerticalScroll||(i=s),e=this.x+(this.hasHorizontalScroll?i*this.options.invertWheelDirection:0),o=this.y+(this.hasVerticalScroll?s*this.options.invertWheelDirection:0),e>0?e=0:e<this.maxScrollX&&(e=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(e,o,0)},_initSnap:function(){this.pages=[],this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},a++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),0===this.options.snapThreshold%1?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){var e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[0].length?i=this.pages[0].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},next:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s++,s>=this.pages.length&&this.hasVericalScroll&&(s=0,e++),this.goToPage(s,e,t,i)},prev:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s--,0>s&&this.hasVericalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in s)this.options.keyBindings[i]=this.options.keyBindings[i]||s[i];a.addEvent(t,"keydown",this),this.on("destroy",function(){a.removeEvent(t,"keydown",this)})},_key:function(t){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=a.getTime(),h=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-h?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0}return e?(this.goToPage(o,n),void 0):(o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r,void 0)},_animate:function(t,i,s,e){function o(){var u,d,m,f=a.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime),void 0):(f=(f-c)/s,m=e(f),u=(t-r)*m+r,d=(i-l)*m+l,n._translate(u,d),n.isAnimating&&h(o),void 0)}var n=this,r=this.x,l=this.y,c=a.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t),this.options.zoom&&t.touches&&t.touches.length>1&&this._zoomStart(t);break;case"touchmove":case"MSPointerMove":case"mousemove":if(this.options.zoom&&t.touches&&t.touches[1])return this._zoom(t),void 0;this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":if(this.scaled)return this._zoomEnd(t),void 0;this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":if("zoom"==this.options.wheelAction)return this._wheelZoom(t),void 0;this._wheel(t);break;case"keydown":this._key(t)}}},r.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(a.removeEvent(this.indicator,"touchstart",this),a.removeEvent(this.indicator,"MSPointerDown",this),a.removeEvent(this.indicator,"mousedown",this),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),a.removeEvent(t,"touchend",this),a.removeEvent(t,"MSPointerUp",this),a.removeEvent(t,"mouseup",this))},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(0),this.initiated=!0,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=a.getTime(),a.addEvent(t,"touchmove",this),a.addEvent(t,"MSPointerMove",this),a.addEvent(t,"mousemove",this)},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t;a.getTime(),i=n.pageX-this.lastPointX,this.lastPointX=n.pageX,s=n.pageY-this.lastPointY,this.lastPointY=n.pageY,e=this.x+i,o=this.y+s,this._pos(e,o),t.preventDefault(),t.stopPropagation()},_end:function(i){this.initiated&&(this.initiated=!1,i.preventDefault(),i.stopPropagation(),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this))},transitionTime:function(t){t=t||0,this.indicatorStyle[a.style.transitionDuration]=t+"ms"},transitionTimingFunction:function(t){this.indicatorStyle[a.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(0),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(a.addClass(this.wrapper,"iScrollBothScrollbars"),a.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(a.removeClass(this.wrapper,"iScrollBothScrollbars"),a.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px")),this.wrapper.offsetHeight,this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.round(this.wrapperWidth*this.wrapperWidth/this.scroller.scrollerWidth),8),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=s.max(s.round(this.wrapperHeight*this.wrapperHeight/this.scroller.scrollerHeight),8),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=s.round(this.sizeRatioX*this.scroller.x)||0,i=s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY)),this.x=t,this.y=i,this.scroller.options.useTransform?this.indicatorStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),this.scroller.scrollTo(s.round(t/this.sizeRatioX),s.round(i/this.sizeRatioY))}},o.ease=a.ease,o}(window,document,Math); | |
| No newline at the end of the file | ||
| 1 | +/*! iScroll v5.0.2 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | +var IScroll=function(t,i,s){function o(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={zoomMin:1,zoomMax:4,resizeIndicator:!0,mouseWheelSpeed:20,snapThreshold:.334,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,HWCompositing:!0,useTransition:!0,useTransform:!0};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&a.hasPerspective?" translateZ(0)":"",this.options.useTransition=a.hasTransition&&this.options.useTransition,this.options.useTransform=a.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1:this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?a.ease[this.options.bounceEasing]||a.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this.scale=1,this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function n(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),s||(o.style.pointerEvents="none"),o.appendChild(n),o}function r(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(a.addEvent(this.indicator,"touchstart",this),a.addEvent(this.indicator,"MSPointerDown",this),a.addEvent(this.indicator,"mousedown",this),a.addEvent(t,"touchend",this),a.addEvent(t,"MSPointerUp",this),a.addEvent(t,"mouseup",this))}var h=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},a=function(){function o(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},r=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in r)return i[s].substr(0,i[s].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var s in i)t[s]=i[s]},n.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},n.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},n.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var a=o("transform");return n.extend(n,{hasTransform:a!==!1,hasPerspective:o("perspective")in r,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:o("transition")in r}),n.isAndroidBrowser=/Android/.test(t.navigator.appVersion)&&/Version\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:a,transitionTimingFunction:o("transitionTimingFunction"),transitionDuration:o("transitionDuration"),transformOrigin:o("transformOrigin")}),n.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s,"")}},n.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return f=.22,e=.4,0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin((t-f/4)*2*s.PI/f)+1}}}),n.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},n.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},n}();return o.prototype={version:"5.0.2",_init:function(){this._initEvents(),this.options.zoom&&this._initZoom(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&(this._transitionTime(0),this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd"))},_start:function(t){if(!(1!=a.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&a.eventType[t.type]!==this.initiated)){this.options.preventDefault&&!a.isAndroidBrowser&&t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=a.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.isAnimating=!1,this.startTime=a.getTime(),this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=e.pageX,this.pointY=e.pageY,this._execEvent("scrollStart")}},_move:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,h=this.hasHorizontalScroll?r.pageX-this.pointX:0,l=this.hasVerticalScroll?r.pageY-this.pointY:0,c=a.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=h,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;h=0}i=this.x+h,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+h/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=h>0?-1:0>h?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,a.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),h=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.scrollTo(n,r),this.isInTransition=0,this.initiated=0,this.endTime=a.getTime(),!this.resetPosition(this.options.bounceTime)){if(!this.moved)return this.options.tap&&a.tap(t,this.options.tap),this.options.click&&a.click(t),void 0;if(this._events.flick&&200>o&&100>h&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?a.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?a.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var d=this._nearestSnap(n,r);this.currentPage=d,n=d.x,r=d.y,c=this.options.snapSpeed||s.max(s.max(s.min(h,1e3),s.min(h,1e3)),300),this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=a.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh()},this.options.resizePolling)},resetPosition:function(t){var i=this.x,s=this.y;return t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),i==this.x&&s==this.y?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){if(this.wrapper.offsetHeight,this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=s.round(this.scroller.offsetWidth*this.scale),this.scrollerHeight=s.round(this.scroller.offsetHeight*this.scale),this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.hasHorizontalScroll||(this.maxScrollX=0,this.scrollerWidth=this.wrapperWidth),this.hasVerticalScroll||(this.maxScrollY=0,this.scrollerHeight=this.wrapperHeight),this.endTime=0,this.directionX=0,this.directionY=0,this.wrapperOffset=a.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition(),this.options.snap){var t=this._nearestSnap(this.x,this.y);if(this.x==t.x&&this.y==t.y)return;this.currentPage=t,this.scrollTo(t.x,t.y)}},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||a.ease.circular,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=a.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=void 0===i||null===i||"auto"===i?s.max(2*s.abs(r.left),2*s.abs(r.top)):i,this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[a.style.transitionDuration]=t+"ms",this.indicator1&&this.indicator1.transitionTime(t),this.indicator2&&this.indicator2.transitionTime(t)},_transitionTimingFunction:function(t){this.scrollerStyle[a.style.transitionTimingFunction]=t,this.indicator1&&this.indicator1.transitionTimingFunction(t),this.indicator2&&this.indicator2.transitionTimingFunction(t)},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[a.style.transform]="translate("+t+"px,"+i+"px) scale("+this.scale+") "+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicator1&&this.indicator1.updatePosition(),this.indicator2&&this.indicator2.updatePosition()},_initEvents:function(i){var s=i?a.removeEvent:a.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this),a.hasPointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),a.hasTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[a.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d]/g,""),s=+e.top.replace(/[^-\d]/g,"")),{x:i,y:s}},_initIndicators:function(){var t,i,s=this.options.interactiveScrollbars;"object"!=typeof this.options.scrollbars,this.options.scrollbars?(this.options.scrollY&&(t={el:n("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenX:!1},this.wrapper.appendChild(t.el)),this.options.scrollX&&(i={el:n("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,resize:this.options.resizeIndicator,listenY:!1},this.wrapper.appendChild(i.el))):(t=this.options.indicators.length?this.options.indicators[0]:this.options.indicators,i=this.options.indicators[1]&&this.options.indicators[1]),t&&(this.indicator1=new r(this,t)),i&&(this.indicator2=new r(this,i)),this.on("refresh",function(){this.indicator1&&this.indicator1.refresh(),this.indicator2&&this.indicator2.refresh()}),this.on("destroy",function(){this.indicator1&&(this.indicator1.destroy(),this.indicator1=null),this.indicator2&&(this.indicator2.destroy(),this.indicator2=null)})},_initZoom:function(){this.scrollerStyle[a.style.transformOrigin]="0 0"},_zoomStart:function(t){var i=s.abs(t.touches[0].pageX-t.touches[1].pageX),e=s.abs(t.touches[0].pageY-t.touches[1].pageY);this.touchesDistanceStart=s.sqrt(i*i+e*e),this.startScale=this.scale,this.originX=s.abs(t.touches[0].pageX+t.touches[1].pageX)/2+this.wrapperOffset.left-this.x,this.originY=s.abs(t.touches[0].pageY+t.touches[1].pageY)/2+this.wrapperOffset.top-this.y,this._execEvent("zoomStart")},_zoom:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n=s.abs(t.touches[0].pageX-t.touches[1].pageX),r=s.abs(t.touches[0].pageY-t.touches[1].pageY),h=s.sqrt(n*n+r*r),l=1/this.touchesDistanceStart*h*this.startScale;this.scaled=!0,l<this.options.zoomMin?l=.5*this.options.zoomMin*s.pow(2,l/this.options.zoomMin):l>this.options.zoomMax&&(l=2*this.options.zoomMax*s.pow(.5,this.options.zoomMax/l)),i=l/this.startScale,e=this.originX-this.originX*i+this.startX,o=this.originY-this.originY*i+this.startY,this.scale=l,this.scrollTo(e,o,0)}},_zoomEnd:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,s,e;this.isInTransition=0,this.initiated=0,this.scale>this.options.zoomMax?this.scale=this.options.zoomMax:this.scale<this.options.zoomMin&&(this.scale=this.options.zoomMin),this.refresh(),e=this.scale/this.startScale,i=this.originX-this.originX*e+this.startX,s=this.originY-this.originY*e+this.startY,i>0?i=0:i<this.maxScrollX&&(i=this.maxScrollX),s>0?s=0:s<this.maxScrollY&&(s=this.maxScrollY),(this.x!=i||this.y!=s)&&this.scrollTo(i,s,this.options.bounceTime),this.scaled=!1,this._execEvent("zoomEnd")}},zoom:function(t,i,s,e){if(t<this.options.zoomMin?t=this.options.zoomMin:t>this.options.zoomMax&&(t=this.options.zoomMax),t!=this.scale){var o=t/this.scale;i=void 0===i?this.wrapperWidth/2:i,s=void 0===s?this.wrapperHeight/2:s,e=void 0===e?300:e,i=i+this.wrapperOffset.left-this.x,s=s+this.wrapperOffset.top-this.y,i=i-i*o+this.x,s=s-s*o+this.y,this.scale=t,this.refresh(),i>0?i=0:i<this.maxScrollX&&(i=this.maxScrollX),s>0?s=0:s<this.maxScrollY&&(s=this.maxScrollY),this.scrollTo(i,s,e)}},_wheelZoom:function(t){var i,e;if("wheelDeltaX"in t)i=t.wheelDeltaY/s.abs(t.wheelDeltaY);else if("wheelDelta"in t)i=t.wheelDelta/s.abs(t.wheelDelta);else{if(!("detail"in t))return;i=-t.detail/s.abs(t.wheelDelta)}e=this.scale+i/5,this.zoom(e,t.pageX,t.pageY,0)},_initWheel:function(){a.addEvent(this.wrapper,"mousewheel",this),a.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){a.removeEvent(this.wrapper,"mousewheel",this),a.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){var i,s,e,o,n=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){n._execEvent("scrollEnd")},400),t.preventDefault(),"wheelDeltaX"in t)i=t.wheelDeltaX/120,s=t.wheelDeltaY/120;else if("wheelDelta"in t)i=s=t.wheelDelta/120;else{if(!("detail"in t))return;i=s=-t.detail/3}i*=this.options.mouseWheelSpeed,s*=this.options.mouseWheelSpeed,this.hasVerticalScroll||(i=s),e=this.x+(this.hasHorizontalScroll?i*this.options.invertWheelDirection:0),o=this.y+(this.hasVerticalScroll?s*this.options.invertWheelDirection:0),e>0?e=0:e<this.maxScrollX&&(e=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(e,o,0)},_initSnap:function(){this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},l>this.maxScrollX&&a++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),0===this.options.snapThreshold%1?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){var e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[0].length?i=this.pages[0].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},next:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s++,s>=this.pages.length&&this.hasVericalScroll&&(s=0,e++),this.goToPage(s,e,t,i)},prev:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s--,0>s&&this.hasVericalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in s)this.options.keyBindings[i]=this.options.keyBindings[i]||s[i];a.addEvent(t,"keydown",this),this.on("destroy",function(){a.removeEvent(t,"keydown",this)})},_key:function(t){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=a.getTime(),h=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-h?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0}return e?(this.goToPage(o,n),void 0):(o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r,void 0)},_animate:function(t,i,s,e){function o(){var d,u,m,f=a.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"),void 0):(f=(f-c)/s,m=e(f),d=(t-r)*m+r,u=(i-l)*m+l,n._translate(d,u),n.isAnimating&&h(o),void 0)}var n=this,r=this.x,l=this.y,c=a.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t),this.options.zoom&&t.touches&&t.touches.length>1&&this._zoomStart(t);break;case"touchmove":case"MSPointerMove":case"mousemove":if(this.options.zoom&&t.touches&&t.touches[1])return this._zoom(t),void 0;this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":if(this.scaled)return this._zoomEnd(t),void 0;this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"DOMMouseScroll":case"mousewheel":if("zoom"==this.options.wheelAction)return this._wheelZoom(t),void 0;this._wheel(t);break;case"keydown":this._key(t)}}},r.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(a.removeEvent(this.indicator,"touchstart",this),a.removeEvent(this.indicator,"MSPointerDown",this),a.removeEvent(this.indicator,"mousedown",this),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),a.removeEvent(t,"touchend",this),a.removeEvent(t,"MSPointerUp",this),a.removeEvent(t,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(0),this.initiated=!0,this.moved=!1,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=a.getTime(),a.addEvent(t,"touchmove",this),a.addEvent(t,"MSPointerMove",this),a.addEvent(t,"mousemove",this),this.scroller._execEvent("scrollStart")},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t;a.getTime(),this.moved=!0,i=n.pageX-this.lastPointX,this.lastPointX=n.pageX,s=n.pageY-this.lastPointY,this.lastPointY=n.pageY,e=this.x+i,o=this.y+s,this._pos(e,o),t.preventDefault(),t.stopPropagation()},_end:function(i){this.initiated&&(this.initiated=!1,i.preventDefault(),i.stopPropagation(),a.removeEvent(t,"touchmove",this),a.removeEvent(t,"MSPointerMove",this),a.removeEvent(t,"mousemove",this),this.moved&&this.scroller._execEvent("scrollEnd"))},transitionTime:function(t){t=t||0,this.indicatorStyle[a.style.transitionDuration]=t+"ms"},transitionTimingFunction:function(t){this.indicatorStyle[a.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(0),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(a.addClass(this.wrapper,"iScrollBothScrollbars"),a.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(a.removeClass(this.wrapper,"iScrollBothScrollbars"),a.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px")),this.wrapper.offsetHeight,this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.round(this.wrapperWidth*this.wrapperWidth/this.scroller.scrollerWidth),8),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=s.max(s.round(this.wrapperHeight*this.wrapperHeight/this.scroller.scrollerHeight),8),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=s.round(this.sizeRatioX*this.scroller.x)||0,i=s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY)),this.x=t,this.y=i,this.scroller.options.useTransform?this.indicatorStyle[a.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),this.scroller.scrollTo(s.round(t/this.sizeRatioX),s.round(i/this.sizeRatioY))}},o.ease=a.ease,o}(window,document,Math); | |
| No newline at the end of the file |
modified package.json +3 −3
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "iscroll", |
| 3 | 3 | "description": "Smooth scrolling for the web", |
| 4 | - "version": "5.0.1", | |
| 4 | + "version": "5.0.2", | |
| 5 | 5 | "homepage": "http://cubiq.org/iscroll-4", |
| 6 | 6 | "author": "Matteo Spinelli <matteo@cubiq.org> (http://cubiq.org)", |
| 7 | 7 | "keywords": [ |
| @@ -13,8 +13,8 @@ | ||
| 13 | 13 | "desktop" |
| 14 | 14 | ], |
| 15 | 15 | "devDependencies": { |
| 16 | - "jshint": "~2.1.3", | |
| 17 | - "uglify-js": "~2.3.4" | |
| 16 | + "jshint": "~2.1.4", | |
| 17 | + "uglify-js": "~2.3.6" | |
| 18 | 18 | }, |
| 19 | 19 | "repository": { |
| 20 | 20 | "type": "git", |
modified src/core.js +43 −24
| @@ -59,6 +59,8 @@ | ||
| 59 | 59 | // Some defaults |
| 60 | 60 | this.x = 0; |
| 61 | 61 | this.y = 0; |
| 62 | + this.directionX = 0; | |
| 63 | + this.directionY = 0; | |
| 62 | 64 | this._events = {}; |
| 63 | 65 | |
| 64 | 66 | // INSERT POINT: DEFAULTS |
| @@ -98,6 +100,13 @@ | ||
| 98 | 100 | }, |
| 99 | 101 | |
| 100 | 102 | _start: function (e) { |
| 103 | + // React to left mouse button only | |
| 104 | + if ( utils.eventType[e.type] != 1 ) { | |
| 105 | + if ( e.button !== 0 ) { | |
| 106 | + return; | |
| 107 | + } | |
| 108 | + } | |
| 109 | + | |
| 101 | 110 | if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { |
| 102 | 111 | return; |
| 103 | 112 | } |
| @@ -129,12 +138,12 @@ | ||
| 129 | 138 | this.isInTransition = false; |
| 130 | 139 | } |
| 131 | 140 | |
| 132 | - this.startX = this.x; | |
| 133 | - this.startY = this.y; | |
| 141 | + this.startX = this.x; | |
| 142 | + this.startY = this.y; | |
| 134 | 143 | this.absStartX = this.x; |
| 135 | 144 | this.absStartY = this.y; |
| 136 | - this.pointX = point.pageX; | |
| 137 | - this.pointY = point.pageY; | |
| 145 | + this.pointX = point.pageX; | |
| 146 | + this.pointY = point.pageY; | |
| 138 | 147 | |
| 139 | 148 | this._execEvent('scrollStart'); |
| 140 | 149 | }, |
| @@ -149,8 +158,8 @@ | ||
| 149 | 158 | } |
| 150 | 159 | |
| 151 | 160 | var point = e.touches ? e.touches[0] : e, |
| 152 | - deltaX = point.pageX - this.pointX, | |
| 153 | - deltaY = point.pageY - this.pointY, | |
| 161 | + deltaX = this.hasHorizontalScroll ? point.pageX - this.pointX : 0, | |
| 162 | + deltaY = this.hasVerticalScroll ? point.pageY - this.pointY : 0, | |
| 154 | 163 | timestamp = utils.getTime(), |
| 155 | 164 | newX, newY, |
| 156 | 165 | absDistX, absDistY; |
| @@ -199,8 +208,8 @@ | ||
| 199 | 208 | deltaX = 0; |
| 200 | 209 | } |
| 201 | 210 | |
| 202 | - newX = this.x + (this.hasHorizontalScroll ? deltaX : 0); | |
| 203 | - newY = this.y + (this.hasVerticalScroll ? deltaY : 0); | |
| 211 | + newX = this.x + deltaX; | |
| 212 | + newY = this.y + deltaY; | |
| 204 | 213 | |
| 205 | 214 | // Slow down if outside of the boundaries |
| 206 | 215 | if ( newX > 0 || newX < this.maxScrollX ) { |
| @@ -299,6 +308,8 @@ | ||
| 299 | 308 | Math.min(distanceX, 1000) |
| 300 | 309 | ), 300); |
| 301 | 310 | |
| 311 | + this.directionX = 0; | |
| 312 | + this.directionY = 0; | |
| 302 | 313 | easing = this.options.bounceEasing; |
| 303 | 314 | } |
| 304 | 315 | |
| @@ -322,15 +333,10 @@ | ||
| 322 | 333 | |
| 323 | 334 | this.resizeTimeout = setTimeout(function () { |
| 324 | 335 | that.refresh(); |
| 325 | - that.resetPosition(); | |
| 326 | 336 | }, this.options.resizePolling); |
| 327 | 337 | }, |
| 328 | 338 | |
| 329 | 339 | resetPosition: function (time) { |
| 330 | - if ( this.x <= 0 && this.x >= this.maxScrollX && this.y <= 0 && this.y >= this.maxScrollY ) { | |
| 331 | - return false; | |
| 332 | - } | |
| 333 | - | |
| 334 | 340 | var x = this.x, |
| 335 | 341 | y = this.y; |
| 336 | 342 | |
| @@ -348,11 +354,8 @@ | ||
| 348 | 354 | y = this.maxScrollY; |
| 349 | 355 | } |
| 350 | 356 | |
| 351 | - if ( this.options.snap ) { | |
| 352 | - var snap = this._nearestSnap(x, y); | |
| 353 | - this.currentPage = snap; | |
| 354 | - x = snap.x; | |
| 355 | - y = snap.y; | |
| 357 | + if ( x == this.x && y == this.y ) { | |
| 358 | + return false; | |
| 356 | 359 | } |
| 357 | 360 | |
| 358 | 361 | this.scrollTo(x, y, time, this.options.bounceEasing); |
| @@ -384,22 +387,38 @@ | ||
| 384 | 387 | this.maxScrollX = this.wrapperWidth - this.scrollerWidth; |
| 385 | 388 | this.maxScrollY = this.wrapperHeight - this.scrollerHeight; |
| 386 | 389 | |
| 387 | - if ( this.maxScrollX > 0 ) { | |
| 390 | + this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 391 | + this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 392 | + | |
| 393 | + if ( !this.hasHorizontalScroll ) { | |
| 388 | 394 | this.maxScrollX = 0; |
| 395 | + this.scrollerWidth = this.wrapperWidth; | |
| 389 | 396 | } |
| 390 | 397 | |
| 391 | - if ( this.maxScrollY > 0 ) { | |
| 398 | + if ( !this.hasVerticalScroll ) { | |
| 392 | 399 | this.maxScrollY = 0; |
| 400 | + this.scrollerHeight = this.wrapperHeight; | |
| 393 | 401 | } |
| 394 | 402 | |
| 395 | - this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; | |
| 396 | - this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; | |
| 397 | - | |
| 398 | 403 | this.endTime = 0; |
| 404 | + this.directionX = 0; | |
| 405 | + this.directionY = 0; | |
| 399 | 406 | |
| 400 | 407 | this.wrapperOffset = utils.offset(this.wrapper); |
| 401 | 408 | |
| 402 | 409 | this._execEvent('refresh'); |
| 410 | + | |
| 411 | + this.resetPosition(); | |
| 412 | + | |
| 413 | + if ( this.options.snap ) { | |
| 414 | + var snap = this._nearestSnap(this.x, this.y); | |
| 415 | + if ( this.x == snap.x && this.y == snap.y ) { | |
| 416 | + return; | |
| 417 | + } | |
| 418 | + | |
| 419 | + this.currentPage = snap; | |
| 420 | + this.scrollTo(snap.x, snap.y); | |
| 421 | + } | |
| 403 | 422 | }, |
| 404 | 423 | |
| 405 | 424 | on: function (type, fn) { |
| @@ -473,7 +492,7 @@ | ||
| 473 | 492 | pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; |
| 474 | 493 | pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; |
| 475 | 494 | |
| 476 | - time = time === undefined || null || 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 495 | + time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(pos.left)*2, Math.abs(pos.top)*2) : time; | |
| 477 | 496 | |
| 478 | 497 | this.scrollTo(pos.left, pos.top, time, easing); |
| 479 | 498 | }, |
modified src/default/_animate.js +5 −1
| @@ -14,7 +14,11 @@ | ||
| 14 | 14 | if ( now >= destTime ) { |
| 15 | 15 | that.isAnimating = false; |
| 16 | 16 | that._translate(destX, destY); |
| 17 | - that.resetPosition(that.options.bounceTime); | |
| 17 | + | |
| 18 | + if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 19 | + that._execEvent('scrollEnd'); | |
| 20 | + } | |
| 21 | + | |
| 18 | 22 | return; |
| 19 | 23 | } |
| 20 | 24 |
modified src/indicator/_initIndicators.js +2 −0
| @@ -57,10 +57,12 @@ | ||
| 57 | 57 | this.on('destroy', function () { |
| 58 | 58 | if ( this.indicator1 ) { |
| 59 | 59 | this.indicator1.destroy(); |
| 60 | + this.indicator1 = null; | |
| 60 | 61 | } |
| 61 | 62 | |
| 62 | 63 | if ( this.indicator2 ) { |
| 63 | 64 | this.indicator2.destroy(); |
| 65 | + this.indicator2 = null; | |
| 64 | 66 | } |
| 65 | 67 | }); |
| 66 | 68 | }, |
modified src/indicator/indicator.js +13 −0
| @@ -107,6 +107,10 @@ | ||
| 107 | 107 | utils.removeEvent(window, 'MSPointerUp', this); |
| 108 | 108 | utils.removeEvent(window, 'mouseup', this); |
| 109 | 109 | } |
| 110 | + | |
| 111 | + if ( this.options.defaultScrollbars ) { | |
| 112 | + this.wrapper.parentNode.removeChild(this.wrapper); | |
| 113 | + } | |
| 110 | 114 | }, |
| 111 | 115 | |
| 112 | 116 | _start: function (e) { |
| @@ -118,6 +122,7 @@ | ||
| 118 | 122 | this.transitionTime(0); |
| 119 | 123 | |
| 120 | 124 | this.initiated = true; |
| 125 | + this.moved = false; | |
| 121 | 126 | this.lastPointX = point.pageX; |
| 122 | 127 | this.lastPointY = point.pageY; |
| 123 | 128 | |
| @@ -126,6 +131,8 @@ | ||
| 126 | 131 | utils.addEvent(window, 'touchmove', this); |
| 127 | 132 | utils.addEvent(window, 'MSPointerMove', this); |
| 128 | 133 | utils.addEvent(window, 'mousemove', this); |
| 134 | + | |
| 135 | + this.scroller._execEvent('scrollStart'); | |
| 129 | 136 | }, |
| 130 | 137 | |
| 131 | 138 | _move: function (e) { |
| @@ -134,6 +141,8 @@ | ||
| 134 | 141 | newX, newY, |
| 135 | 142 | timestamp = utils.getTime(); |
| 136 | 143 | |
| 144 | + this.moved = true; | |
| 145 | + | |
| 137 | 146 | deltaX = point.pageX - this.lastPointX; |
| 138 | 147 | this.lastPointX = point.pageX; |
| 139 | 148 | |
| @@ -162,6 +171,10 @@ | ||
| 162 | 171 | utils.removeEvent(window, 'touchmove', this); |
| 163 | 172 | utils.removeEvent(window, 'MSPointerMove', this); |
| 164 | 173 | utils.removeEvent(window, 'mousemove', this); |
| 174 | + | |
| 175 | + if ( this.moved ) { | |
| 176 | + this.scroller._execEvent('scrollEnd'); | |
| 177 | + } | |
| 165 | 178 | }, |
| 166 | 179 | |
| 167 | 180 | transitionTime: function (time) { |
modified src/probe/_animate.js +33 −33
| @@ -1,42 +1,42 @@ | ||
| 1 | 1 | |
| 2 | -_animate: function (destX, destY, duration, easingFn) { | |
| 3 | - var that = this, | |
| 4 | - startX = this.x, | |
| 5 | - startY = this.y, | |
| 6 | - startTime = utils.getTime(), | |
| 7 | - destTime = startTime + duration; | |
| 2 | + _animate: function (destX, destY, duration, easingFn) { | |
| 3 | + var that = this, | |
| 4 | + startX = this.x, | |
| 5 | + startY = this.y, | |
| 6 | + startTime = utils.getTime(), | |
| 7 | + destTime = startTime + duration; | |
| 8 | 8 | |
| 9 | - function step () { | |
| 10 | - var now = utils.getTime(), | |
| 11 | - newX, newY, | |
| 12 | - easing; | |
| 9 | + function step () { | |
| 10 | + var now = utils.getTime(), | |
| 11 | + newX, newY, | |
| 12 | + easing; | |
| 13 | 13 | |
| 14 | - if ( now >= destTime ) { | |
| 15 | - that.isAnimating = false; | |
| 16 | - that._translate(destX, destY); | |
| 17 | - | |
| 18 | - if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 19 | - that._execEvent('scrollEnd'); | |
| 20 | - } | |
| 14 | + if ( now >= destTime ) { | |
| 15 | + that.isAnimating = false; | |
| 16 | + that._translate(destX, destY); | |
| 17 | + | |
| 18 | + if ( !that.resetPosition(that.options.bounceTime) ) { | |
| 19 | + that._execEvent('scrollEnd'); | |
| 20 | + } | |
| 21 | 21 | |
| 22 | - return; | |
| 23 | - } | |
| 22 | + return; | |
| 23 | + } | |
| 24 | 24 | |
| 25 | - now = ( now - startTime ) / duration; | |
| 26 | - easing = easingFn(now); | |
| 27 | - newX = ( destX - startX ) * easing + startX; | |
| 28 | - newY = ( destY - startY ) * easing + startY; | |
| 29 | - that._translate(newX, newY); | |
| 25 | + now = ( now - startTime ) / duration; | |
| 26 | + easing = easingFn(now); | |
| 27 | + newX = ( destX - startX ) * easing + startX; | |
| 28 | + newY = ( destY - startY ) * easing + startY; | |
| 29 | + that._translate(newX, newY); | |
| 30 | 30 | |
| 31 | - if ( that.isAnimating ) { | |
| 32 | - rAF(step); | |
| 33 | - } | |
| 31 | + if ( that.isAnimating ) { | |
| 32 | + rAF(step); | |
| 33 | + } | |
| 34 | 34 | |
| 35 | - if ( that.options.probeType == 3 ) { | |
| 36 | - that._execEvent('scroll'); | |
| 35 | + if ( that.options.probeType == 3 ) { | |
| 36 | + that._execEvent('scroll'); | |
| 37 | + } | |
| 37 | 38 | } |
| 38 | - } | |
| 39 | 39 | |
| 40 | - this.isAnimating = true; | |
| 41 | - step(); | |
| 42 | -}, | |
| 40 | + this.isAnimating = true; | |
| 41 | + step(); | |
| 42 | + }, |
modified src/snap/snap.js +6 −2
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | |
| 2 | 2 | _initSnap: function () { |
| 3 | - this.pages = []; | |
| 4 | 3 | this.currentPage = {}; |
| 5 | 4 | |
| 6 | 5 | if ( typeof this.options.snap == 'string' ) { |
| @@ -16,6 +15,8 @@ | ||
| 16 | 15 | stepY = this.options.snapStepY || this.wrapperHeight, |
| 17 | 16 | el; |
| 18 | 17 | |
| 18 | + this.pages = []; | |
| 19 | + | |
| 19 | 20 | if ( this.options.snap === true ) { |
| 20 | 21 | cx = Math.round( stepX / 2 ); |
| 21 | 22 | cy = Math.round( stepY / 2 ); |
| @@ -71,7 +72,9 @@ | ||
| 71 | 72 | cy: cy |
| 72 | 73 | }; |
| 73 | 74 | |
| 74 | - m++; | |
| 75 | + if ( x > this.maxScrollX ) { | |
| 76 | + m++; | |
| 77 | + } | |
| 75 | 78 | } |
| 76 | 79 | } |
| 77 | 80 | |
| @@ -107,6 +110,7 @@ | ||
| 107 | 110 | l = this.pages.length, |
| 108 | 111 | m = 0; |
| 109 | 112 | |
| 113 | + // Check if we exceeded the snap threshold | |
| 110 | 114 | if ( Math.abs(x - this.absStartX) < this.snapThresholdX && |
| 111 | 115 | Math.abs(y - this.absStartY) < this.snapThresholdY ) { |
| 112 | 116 | return this.currentPage; |
modified src/wheel/build.json +1 −0
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "insert": { |
| 3 | + "OPTIONS": "\t\tmouseWheelSpeed: 20,", | |
| 3 | 4 | "NORMALIZATION": "\tthis.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;", |
| 4 | 5 | "_init": "\t\tif ( this.options.mouseWheel ) {\n\t\t\tthis._initWheel();\n\t\t}" |
| 5 | 6 | } |
modified src/wheel/wheel.js +2 −2
| @@ -33,8 +33,8 @@ | ||
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - wheelDeltaX *= 10; | |
| 37 | - wheelDeltaY *= 10; | |
| 36 | + wheelDeltaX *= this.options.mouseWheelSpeed; | |
| 37 | + wheelDeltaY *= this.options.mouseWheelSpeed; | |
| 38 | 38 | |
| 39 | 39 | if ( !this.hasVerticalScroll ) { |
| 40 | 40 | wheelDeltaX = wheelDeltaY; |