Changesets · Branches · Tags · Compare
| Changeset | 5d8d38fb472e908bfbc11a0a2679dbc7fe166b0a0b55f1df848e20c7b567bcac |
|---|---|
| Author | cubiq <matteo@cubiq.org> · 2014-01-09 19:27 +01:00 |
| Committer | cubiq <matteo@cubiq.org> · 2014-01-09 19:27 +01:00 |
| Parents | 2a7edf4adfad |
15 files changed
modified .nodemonignore +2 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | /build/* |
| 2 | 2 | /dist/* |
| 3 | 3 | /demos/* |
| 4 | -*.md | |
| No newline at the end of the file | ||
| 4 | +*.md | |
| 5 | +*.tmp | |
| No newline at the end of the file |
modified README.md +12 −4
| @@ -1,4 +1,4 @@ | ||
| 1 | -# iScroll, smooth scrolling for the web | |
| 1 | +<h1 id="intro">iScroll, smooth scrolling for the web</h1> | |
| 2 | 2 | |
| 3 | 3 | iScroll is a high performance, small footprint, dependency free, multi-platform javascript scroller. |
| 4 | 4 | |
| @@ -71,7 +71,9 @@ | ||
| 71 | 71 | Note that iScroll uses `querySelector` not `querySelectorAll`, so only the first occurrence of the selector is used. If you need to apply iScroll to multiple objects you'll have to build your own cycle. |
| 72 | 72 | |
| 73 | 73 | <div class="tip"> |
| 74 | -<p>You don't strictly need to assign the instance to a variable (<code>myScroll</code>), but it is handy to keep a reference to the iScroll (for example you could later check the scroller position).</p> | |
| 74 | +<p>You don't strictly need to assign the instance to a variable (<code>myScroll</code>), but it is handy to keep a reference to the iScroll.</p> | |
| 75 | + | |
| 76 | +For example you could later check the <a href="#scroller-info">scroller position</a> or <a href="#destroy">unload unnecessary events</a> when you don't need the iScroll anymore.</p> | |
| 75 | 77 | </div> |
| 76 | 78 | |
| 77 | 79 | <h2 id="initialization">Initialization</h2> |
| @@ -415,7 +417,7 @@ | ||
| 415 | 417 | |
| 416 | 418 | Have a look at the [minimap demo](http://lab.cubiq.org/iscroll5/demos/minimap/) to get a glance at the power of the `indicators` option. |
| 417 | 419 | |
| 418 | -The wittiest of you would have noticed that `indicators` is actually plural... Yes, exactly, passing an array of objects you can have a virtually infinite number of indicators. I don't what you may need them for, but hey! who am I to argue about your scrollbar preferences? | |
| 420 | +The wittiest of you would have noticed that `indicators` is actually plural... Yes, exactly, passing an array of objects you can have a virtually infinite number of indicators. I don't know what you may need them for, but hey! who am I to argue about your scrollbar preferences? | |
| 419 | 421 | |
| 420 | 422 | ## <span id="parallax-scrolling">Parallax scrolling</span> |
| 421 | 423 | |
| @@ -610,6 +612,12 @@ | ||
| 610 | 612 | |
| 611 | 613 | Default: `600` |
| 612 | 614 | |
| 615 | +### <small>options.</small>deceleration | |
| 616 | + | |
| 617 | +This value can be altered to change the momentum animation duration/speed. Higher numbers make the animation shorter. Sensible results can be experienced starting with a value of `0.01`, bigger than that basically doesn't make any momentum at all. | |
| 618 | + | |
| 619 | +Default: `0.0006` | |
| 620 | + | |
| 613 | 621 | ### <small>options.</small>mouseWheelSpeed |
| 614 | 622 | |
| 615 | 623 | Set the speed of the mouse wheel. |
| @@ -766,7 +774,7 @@ | ||
| 766 | 774 | <h2 id="license">License (MIT)</h2> |
| 767 | 775 | |
| 768 | 776 | |
| 769 | -Copyright (c) 2014 Matteo Spinelli, http://cubiq.org/ | |
| 777 | +Copyright (c) 2014 Matteo Spinelli, [cubiq.org](http://cubiq.org/) | |
| 770 | 778 | |
| 771 | 779 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| 772 | 780 |
added RELEASENOTES.md +34 −0
| @@ -0,0 +1,34 @@ | ||
| 1 | +# Release notes for iScroll | |
| 2 | + | |
| 3 | +--- | |
| 4 | + | |
| 5 | +## Version 5.1.1 - 2014.01.10 | |
| 6 | + | |
| 7 | +### Fixes | |
| 8 | +* Infinite scroll now switch from `transform` to `top/left` based on `useTransform` option. | |
| 9 | +* [#555](https://github.com/cubiq/iscroll/issues/555) removed unused variable | |
| 10 | +* [#372](https://github.com/cubiq/iscroll/issues/372) case insensitive check on tag names | |
| 11 | + | |
| 12 | +### New features | |
| 13 | +* New `off` method to unload custom events | |
| 14 | +* Added `options.deceleration` to alter the momentum duration/speed | |
| 15 | +* Added release notes file | |
| 16 | + | |
| 17 | +--- | |
| 18 | + | |
| 19 | +## Version 5.1.0 - 2014.01.09 | |
| 20 | + | |
| 21 | +### Fixes | |
| 22 | +* [#558](https://github.com/cubiq/iscroll/issues/558) false positive for `isBadAndroid` | |
| 23 | + | |
| 24 | +### New features | |
| 25 | +* Infinite scrolling | |
| 26 | +* Documentation | |
| 27 | +* `_execEvent` supports arguments | |
| 28 | + | |
| 29 | +### Changes | |
| 30 | +* dist/minified files are no longer pushed to the main repo | |
| 31 | + | |
| 32 | +--- | |
| 33 | + | |
| 34 | +*I started collecting release notes from version 5.1.0* | |
| No newline at the end of the file |
modified build/iscroll-infinite.js +30 −9
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | (function (window, document, Math) { |
| 3 | 3 | var rAF = window.requestAnimationFrame || |
| 4 | 4 | window.webkitRequestAnimationFrame || |
| @@ -47,12 +47,13 @@ | ||
| 47 | 47 | el.removeEventListener(type, fn, !!capture); |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | - me.momentum = function (current, start, time, lowerMargin, wrapperSize) { | |
| 50 | + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { | |
| 51 | 51 | var distance = current - start, |
| 52 | 52 | speed = Math.abs(distance) / time, |
| 53 | 53 | destination, |
| 54 | - duration, | |
| 55 | - deceleration = 0.0006; | |
| 54 | + duration; | |
| 55 | + | |
| 56 | + deceleration = deceleration === undefined ? 0.0006 : deceleration; | |
| 56 | 57 | |
| 57 | 58 | destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); |
| 58 | 59 | duration = speed / deceleration; |
| @@ -219,7 +220,7 @@ | ||
| 219 | 220 | var target = e.target, |
| 220 | 221 | ev; |
| 221 | 222 | |
| 222 | - if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') { | |
| 223 | + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { | |
| 223 | 224 | ev = document.createEvent('MouseEvents'); |
| 224 | 225 | ev.initMouseEvent('click', true, true, e.view, 1, |
| 225 | 226 | target.screenX, target.screenY, target.clientX, target.clientY, |
| @@ -245,6 +246,9 @@ | ||
| 245 | 246 | |
| 246 | 247 | snapThreshold: 0.334, |
| 247 | 248 | |
| 249 | + infiniteUseTransform: true, | |
| 250 | + deceleration: 0.004, | |
| 251 | + | |
| 248 | 252 | // INSERT POINT: OPTIONS |
| 249 | 253 | |
| 250 | 254 | startX: 0, |
| @@ -299,6 +303,7 @@ | ||
| 299 | 303 | if ( this.options.infiniteElements ) { |
| 300 | 304 | this.options.probeType = 3; |
| 301 | 305 | } |
| 306 | + this.options.infiniteUseTransform = this.options.infiniteUseTransform && this.options.useTransform; | |
| 302 | 307 | |
| 303 | 308 | if ( this.options.probeType == 3 ) { |
| 304 | 309 | this.options.useTransition = false; } |
| @@ -322,7 +327,7 @@ | ||
| 322 | 327 | } |
| 323 | 328 | |
| 324 | 329 | IScroll.prototype = { |
| 325 | - version: '5.1.0', | |
| 330 | + version: '5.1.1', | |
| 326 | 331 | |
| 327 | 332 | _init: function () { |
| 328 | 333 | this._initEvents(); |
| @@ -571,8 +576,8 @@ | ||
| 571 | 576 | |
| 572 | 577 | // start momentum animation if needed |
| 573 | 578 | if ( this.options.momentum && duration < 300 ) { |
| 574 | - momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 }; | |
| 575 | - momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 }; | |
| 579 | + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; | |
| 580 | + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; | |
| 576 | 581 | newX = momentumX.destination; |
| 577 | 582 | newY = momentumY.destination; |
| 578 | 583 | time = Math.max(momentumX.duration, momentumY.duration); |
| @@ -711,6 +716,18 @@ | ||
| 711 | 716 | this._events[type].push(fn); |
| 712 | 717 | }, |
| 713 | 718 | |
| 719 | + off: function (type, fn) { | |
| 720 | + if ( !this._events[type] ) { | |
| 721 | + return; | |
| 722 | + } | |
| 723 | + | |
| 724 | + var index = this._events[type].indexOf(fn); | |
| 725 | + | |
| 726 | + if ( index > -1 ) { | |
| 727 | + this._events[type].splice(index, 1); | |
| 728 | + } | |
| 729 | + }, | |
| 730 | + | |
| 714 | 731 | _execEvent: function (type) { |
| 715 | 732 | if ( !this._events[type] ) { |
| 716 | 733 | return; |
| @@ -1443,7 +1460,11 @@ | ||
| 1443 | 1460 | |
| 1444 | 1461 | if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) { |
| 1445 | 1462 | this.infiniteElements[i]._top = top; |
| 1446 | - this.infiniteElements[i].style.top = top + 'px'; | |
| 1463 | + if ( this.options.infiniteUseTransform ) { | |
| 1464 | + this.infiniteElements[i].style[utils.style.transform] = 'translate(0, ' + top + 'px)' + this.translateZ; | |
| 1465 | + } else { | |
| 1466 | + this.infiniteElements[i].style.top = top + 'px'; | |
| 1467 | + } | |
| 1447 | 1468 | update.push(this.infiniteElements[i]); |
| 1448 | 1469 | } |
| 1449 | 1470 | } |
modified build/iscroll-lite.js +21 −8
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | (function (window, document, Math) { |
| 3 | 3 | var rAF = window.requestAnimationFrame || |
| 4 | 4 | window.webkitRequestAnimationFrame || |
| @@ -47,12 +47,13 @@ | ||
| 47 | 47 | el.removeEventListener(type, fn, !!capture); |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | - me.momentum = function (current, start, time, lowerMargin, wrapperSize) { | |
| 50 | + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { | |
| 51 | 51 | var distance = current - start, |
| 52 | 52 | speed = Math.abs(distance) / time, |
| 53 | 53 | destination, |
| 54 | - duration, | |
| 55 | - deceleration = 0.0006; | |
| 54 | + duration; | |
| 55 | + | |
| 56 | + deceleration = deceleration === undefined ? 0.0006 : deceleration; | |
| 56 | 57 | |
| 57 | 58 | destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); |
| 58 | 59 | duration = speed / deceleration; |
| @@ -219,7 +220,7 @@ | ||
| 219 | 220 | var target = e.target, |
| 220 | 221 | ev; |
| 221 | 222 | |
| 222 | - if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') { | |
| 223 | + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { | |
| 223 | 224 | ev = document.createEvent('MouseEvents'); |
| 224 | 225 | ev.initMouseEvent('click', true, true, e.view, 1, |
| 225 | 226 | target.screenX, target.screenY, target.clientX, target.clientY, |
| @@ -309,7 +310,7 @@ | ||
| 309 | 310 | } |
| 310 | 311 | |
| 311 | 312 | IScroll.prototype = { |
| 312 | - version: '5.1.0', | |
| 313 | + version: '5.1.1', | |
| 313 | 314 | |
| 314 | 315 | _init: function () { |
| 315 | 316 | this._initEvents(); |
| @@ -536,8 +537,8 @@ | ||
| 536 | 537 | |
| 537 | 538 | // start momentum animation if needed |
| 538 | 539 | if ( this.options.momentum && duration < 300 ) { |
| 539 | - momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 }; | |
| 540 | - momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 }; | |
| 540 | + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; | |
| 541 | + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; | |
| 541 | 542 | newX = momentumX.destination; |
| 542 | 543 | newY = momentumY.destination; |
| 543 | 544 | time = Math.max(momentumX.duration, momentumY.duration); |
| @@ -655,6 +656,18 @@ | ||
| 655 | 656 | this._events[type].push(fn); |
| 656 | 657 | }, |
| 657 | 658 | |
| 659 | + off: function (type, fn) { | |
| 660 | + if ( !this._events[type] ) { | |
| 661 | + return; | |
| 662 | + } | |
| 663 | + | |
| 664 | + var index = this._events[type].indexOf(fn); | |
| 665 | + | |
| 666 | + if ( index > -1 ) { | |
| 667 | + this._events[type].splice(index, 1); | |
| 668 | + } | |
| 669 | + }, | |
| 670 | + | |
| 658 | 671 | _execEvent: function (type) { |
| 659 | 672 | if ( !this._events[type] ) { |
| 660 | 673 | return; |
modified build/iscroll-probe.js +21 −9
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | (function (window, document, Math) { |
| 3 | 3 | var rAF = window.requestAnimationFrame || |
| 4 | 4 | window.webkitRequestAnimationFrame || |
| @@ -47,12 +47,13 @@ | ||
| 47 | 47 | el.removeEventListener(type, fn, !!capture); |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | - me.momentum = function (current, start, time, lowerMargin, wrapperSize) { | |
| 50 | + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { | |
| 51 | 51 | var distance = current - start, |
| 52 | 52 | speed = Math.abs(distance) / time, |
| 53 | 53 | destination, |
| 54 | - duration, | |
| 55 | - deceleration = 0.0006; | |
| 54 | + duration; | |
| 55 | + | |
| 56 | + deceleration = deceleration === undefined ? 0.0006 : deceleration; | |
| 56 | 57 | |
| 57 | 58 | destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); |
| 58 | 59 | duration = speed / deceleration; |
| @@ -219,7 +220,7 @@ | ||
| 219 | 220 | var target = e.target, |
| 220 | 221 | ev; |
| 221 | 222 | |
| 222 | - if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') { | |
| 223 | + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { | |
| 223 | 224 | ev = document.createEvent('MouseEvents'); |
| 224 | 225 | ev.initMouseEvent('click', true, true, e.view, 1, |
| 225 | 226 | target.screenX, target.screenY, target.clientX, target.clientY, |
| @@ -324,7 +325,7 @@ | ||
| 324 | 325 | } |
| 325 | 326 | |
| 326 | 327 | IScroll.prototype = { |
| 327 | - version: '5.1.0', | |
| 328 | + version: '5.1.1', | |
| 328 | 329 | |
| 329 | 330 | _init: function () { |
| 330 | 331 | this._initEvents(); |
| @@ -573,8 +574,8 @@ | ||
| 573 | 574 | |
| 574 | 575 | // start momentum animation if needed |
| 575 | 576 | if ( this.options.momentum && duration < 300 ) { |
| 576 | - momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 }; | |
| 577 | - momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 }; | |
| 577 | + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; | |
| 578 | + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; | |
| 578 | 579 | newX = momentumX.destination; |
| 579 | 580 | newY = momentumY.destination; |
| 580 | 581 | time = Math.max(momentumX.duration, momentumY.duration); |
| @@ -709,6 +710,18 @@ | ||
| 709 | 710 | this._events[type].push(fn); |
| 710 | 711 | }, |
| 711 | 712 | |
| 713 | + off: function (type, fn) { | |
| 714 | + if ( !this._events[type] ) { | |
| 715 | + return; | |
| 716 | + } | |
| 717 | + | |
| 718 | + var index = this._events[type].indexOf(fn); | |
| 719 | + | |
| 720 | + if ( index > -1 ) { | |
| 721 | + this._events[type].splice(index, 1); | |
| 722 | + } | |
| 723 | + }, | |
| 724 | + | |
| 712 | 725 | _execEvent: function (type) { |
| 713 | 726 | if ( !this._events[type] ) { |
| 714 | 727 | return; |
| @@ -902,7 +915,6 @@ | ||
| 902 | 915 | |
| 903 | 916 | _initIndicators: function () { |
| 904 | 917 | var interactive = this.options.interactiveScrollbars, |
| 905 | - defaultScrollbars = typeof this.options.scrollbars != 'object', | |
| 906 | 918 | customStyle = typeof this.options.scrollbars != 'string', |
| 907 | 919 | indicators = [], |
| 908 | 920 | indicator; |
modified build/iscroll-zoom.js +21 −9
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | (function (window, document, Math) { |
| 3 | 3 | var rAF = window.requestAnimationFrame || |
| 4 | 4 | window.webkitRequestAnimationFrame || |
| @@ -47,12 +47,13 @@ | ||
| 47 | 47 | el.removeEventListener(type, fn, !!capture); |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | - me.momentum = function (current, start, time, lowerMargin, wrapperSize) { | |
| 50 | + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { | |
| 51 | 51 | var distance = current - start, |
| 52 | 52 | speed = Math.abs(distance) / time, |
| 53 | 53 | destination, |
| 54 | - duration, | |
| 55 | - deceleration = 0.0006; | |
| 54 | + duration; | |
| 55 | + | |
| 56 | + deceleration = deceleration === undefined ? 0.0006 : deceleration; | |
| 56 | 57 | |
| 57 | 58 | destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); |
| 58 | 59 | duration = speed / deceleration; |
| @@ -219,7 +220,7 @@ | ||
| 219 | 220 | var target = e.target, |
| 220 | 221 | ev; |
| 221 | 222 | |
| 222 | - if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') { | |
| 223 | + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { | |
| 223 | 224 | ev = document.createEvent('MouseEvents'); |
| 224 | 225 | ev.initMouseEvent('click', true, true, e.view, 1, |
| 225 | 226 | target.screenX, target.screenY, target.clientX, target.clientY, |
| @@ -326,7 +327,7 @@ | ||
| 326 | 327 | } |
| 327 | 328 | |
| 328 | 329 | IScroll.prototype = { |
| 329 | - version: '5.1.0', | |
| 330 | + version: '5.1.1', | |
| 330 | 331 | |
| 331 | 332 | _init: function () { |
| 332 | 333 | this._initEvents(); |
| @@ -573,8 +574,8 @@ | ||
| 573 | 574 | |
| 574 | 575 | // start momentum animation if needed |
| 575 | 576 | if ( this.options.momentum && duration < 300 ) { |
| 576 | - momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 }; | |
| 577 | - momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 }; | |
| 577 | + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; | |
| 578 | + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; | |
| 578 | 579 | newX = momentumX.destination; |
| 579 | 580 | newY = momentumY.destination; |
| 580 | 581 | time = Math.max(momentumX.duration, momentumY.duration); |
| @@ -707,6 +708,18 @@ | ||
| 707 | 708 | this._events[type].push(fn); |
| 708 | 709 | }, |
| 709 | 710 | |
| 711 | + off: function (type, fn) { | |
| 712 | + if ( !this._events[type] ) { | |
| 713 | + return; | |
| 714 | + } | |
| 715 | + | |
| 716 | + var index = this._events[type].indexOf(fn); | |
| 717 | + | |
| 718 | + if ( index > -1 ) { | |
| 719 | + this._events[type].splice(index, 1); | |
| 720 | + } | |
| 721 | + }, | |
| 722 | + | |
| 710 | 723 | _execEvent: function (type) { |
| 711 | 724 | if ( !this._events[type] ) { |
| 712 | 725 | return; |
| @@ -896,7 +909,6 @@ | ||
| 896 | 909 | |
| 897 | 910 | _initIndicators: function () { |
| 898 | 911 | var interactive = this.options.interactiveScrollbars, |
| 899 | - defaultScrollbars = typeof this.options.scrollbars != 'object', | |
| 900 | 912 | customStyle = typeof this.options.scrollbars != 'string', |
| 901 | 913 | indicators = [], |
| 902 | 914 | indicator; |
modified build/iscroll.js +21 −9
| @@ -1,4 +1,4 @@ | ||
| 1 | -/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 1 | +/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | 2 | (function (window, document, Math) { |
| 3 | 3 | var rAF = window.requestAnimationFrame || |
| 4 | 4 | window.webkitRequestAnimationFrame || |
| @@ -47,12 +47,13 @@ | ||
| 47 | 47 | el.removeEventListener(type, fn, !!capture); |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | - me.momentum = function (current, start, time, lowerMargin, wrapperSize) { | |
| 50 | + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { | |
| 51 | 51 | var distance = current - start, |
| 52 | 52 | speed = Math.abs(distance) / time, |
| 53 | 53 | destination, |
| 54 | - duration, | |
| 55 | - deceleration = 0.0006; | |
| 54 | + duration; | |
| 55 | + | |
| 56 | + deceleration = deceleration === undefined ? 0.0006 : deceleration; | |
| 56 | 57 | |
| 57 | 58 | destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); |
| 58 | 59 | duration = speed / deceleration; |
| @@ -219,7 +220,7 @@ | ||
| 219 | 220 | var target = e.target, |
| 220 | 221 | ev; |
| 221 | 222 | |
| 222 | - if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') { | |
| 223 | + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { | |
| 223 | 224 | ev = document.createEvent('MouseEvents'); |
| 224 | 225 | ev.initMouseEvent('click', true, true, e.view, 1, |
| 225 | 226 | target.screenX, target.screenY, target.clientX, target.clientY, |
| @@ -321,7 +322,7 @@ | ||
| 321 | 322 | } |
| 322 | 323 | |
| 323 | 324 | IScroll.prototype = { |
| 324 | - version: '5.1.0', | |
| 325 | + version: '5.1.1', | |
| 325 | 326 | |
| 326 | 327 | _init: function () { |
| 327 | 328 | this._initEvents(); |
| @@ -564,8 +565,8 @@ | ||
| 564 | 565 | |
| 565 | 566 | // start momentum animation if needed |
| 566 | 567 | if ( this.options.momentum && duration < 300 ) { |
| 567 | - momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 }; | |
| 568 | - momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 }; | |
| 568 | + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; | |
| 569 | + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; | |
| 569 | 570 | newX = momentumX.destination; |
| 570 | 571 | newY = momentumY.destination; |
| 571 | 572 | time = Math.max(momentumX.duration, momentumY.duration); |
| @@ -700,6 +701,18 @@ | ||
| 700 | 701 | this._events[type].push(fn); |
| 701 | 702 | }, |
| 702 | 703 | |
| 704 | + off: function (type, fn) { | |
| 705 | + if ( !this._events[type] ) { | |
| 706 | + return; | |
| 707 | + } | |
| 708 | + | |
| 709 | + var index = this._events[type].indexOf(fn); | |
| 710 | + | |
| 711 | + if ( index > -1 ) { | |
| 712 | + this._events[type].splice(index, 1); | |
| 713 | + } | |
| 714 | + }, | |
| 715 | + | |
| 703 | 716 | _execEvent: function (type) { |
| 704 | 717 | if ( !this._events[type] ) { |
| 705 | 718 | return; |
| @@ -893,7 +906,6 @@ | ||
| 893 | 906 | |
| 894 | 907 | _initIndicators: function () { |
| 895 | 908 | var interactive = this.options.interactiveScrollbars, |
| 896 | - defaultScrollbars = typeof this.options.scrollbars != 'object', | |
| 897 | 909 | customStyle = typeof this.options.scrollbars != 'string', |
| 898 | 910 | indicators = [], |
| 899 | 911 | indicator; |
modified demos/infinite/index.html +0 −1
| @@ -67,7 +67,6 @@ | ||
| 67 | 67 | dataFiller: updateContent, |
| 68 | 68 | cacheSize: 1000 |
| 69 | 69 | }); |
| 70 | - console.log(myScroll.options) | |
| 71 | 70 | } |
| 72 | 71 | |
| 73 | 72 | function requestData (start, count) { |
modified package.json +1 −1
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "iscroll", |
| 3 | 3 | "description": "Smooth scrolling for the web", |
| 4 | - "version": "5.1.0", | |
| 4 | + "version": "5.1.1", | |
| 5 | 5 | "homepage": "http://cubiq.org/iscroll-4", |
| 6 | 6 | "author": "Matteo Spinelli <matteo@cubiq.org> (http://cubiq.org)", |
| 7 | 7 | "keywords": [ |
modified src/core.js +14 −2
| @@ -301,8 +301,8 @@ | ||
| 301 | 301 | |
| 302 | 302 | // start momentum animation if needed |
| 303 | 303 | if ( this.options.momentum && duration < 300 ) { |
| 304 | - momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 }; | |
| 305 | - momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 }; | |
| 304 | + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; | |
| 305 | + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; | |
| 306 | 306 | newX = momentumX.destination; |
| 307 | 307 | newY = momentumY.destination; |
| 308 | 308 | time = Math.max(momentumX.duration, momentumY.duration); |
| @@ -420,6 +420,18 @@ | ||
| 420 | 420 | this._events[type].push(fn); |
| 421 | 421 | }, |
| 422 | 422 | |
| 423 | + off: function (type, fn) { | |
| 424 | + if ( !this._events[type] ) { | |
| 425 | + return; | |
| 426 | + } | |
| 427 | + | |
| 428 | + var index = this._events[type].indexOf(fn); | |
| 429 | + | |
| 430 | + if ( index > -1 ) { | |
| 431 | + this._events[type].splice(index, 1); | |
| 432 | + } | |
| 433 | + }, | |
| 434 | + | |
| 423 | 435 | _execEvent: function (type) { |
| 424 | 436 | if ( !this._events[type] ) { |
| 425 | 437 | return; |
modified src/indicator/_initIndicators.js +0 −1
| @@ -1,7 +1,6 @@ | ||
| 1 | 1 | |
| 2 | 2 | _initIndicators: function () { |
| 3 | 3 | var interactive = this.options.interactiveScrollbars, |
| 4 | - defaultScrollbars = typeof this.options.scrollbars != 'object', | |
| 5 | 4 | customStyle = typeof this.options.scrollbars != 'string', |
| 6 | 5 | indicators = [], |
| 7 | 6 | indicator; |
modified src/infinite/build.json +2 −1
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "insert": { |
| 3 | - "NORMALIZATION": "\tif ( this.options.infiniteElements ) {\n\t\tthis.options.probeType = 3;\n\t}", | |
| 3 | + "OPTIONS": "\t\tinfiniteUseTransform: true,\n\t\tdeceleration: 0.004,", | |
| 4 | + "NORMALIZATION": "\tif ( this.options.infiniteElements ) {\n\t\tthis.options.probeType = 3;\n\t}\n\tthis.options.infiniteUseTransform = this.options.infiniteUseTransform && this.options.useTransform;", | |
| 4 | 5 | "_init": "\t\tif ( this.options.infiniteElements ) {\n\t\t\tthis._initInfinite();\n\t\t}" |
| 5 | 6 | }, |
| 6 | 7 | "replace": { |
modified src/infinite/infinite.js +5 −1
| @@ -50,7 +50,11 @@ | ||
| 50 | 50 | |
| 51 | 51 | if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) { |
| 52 | 52 | this.infiniteElements[i]._top = top; |
| 53 | - this.infiniteElements[i].style.top = top + 'px'; | |
| 53 | + if ( this.options.infiniteUseTransform ) { | |
| 54 | + this.infiniteElements[i].style[utils.style.transform] = 'translate(0, ' + top + 'px)' + this.translateZ; | |
| 55 | + } else { | |
| 56 | + this.infiniteElements[i].style.top = top + 'px'; | |
| 57 | + } | |
| 54 | 58 | update.push(this.infiniteElements[i]); |
| 55 | 59 | } |
| 56 | 60 | } |
modified src/utils.js +5 −4
| @@ -45,12 +45,13 @@ | ||
| 45 | 45 | el.removeEventListener(type, fn, !!capture); |
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | - me.momentum = function (current, start, time, lowerMargin, wrapperSize) { | |
| 48 | + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { | |
| 49 | 49 | var distance = current - start, |
| 50 | 50 | speed = Math.abs(distance) / time, |
| 51 | 51 | destination, |
| 52 | - duration, | |
| 53 | - deceleration = 0.0006; | |
| 52 | + duration; | |
| 53 | + | |
| 54 | + deceleration = deceleration === undefined ? 0.0006 : deceleration; | |
| 54 | 55 | |
| 55 | 56 | destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); |
| 56 | 57 | duration = speed / deceleration; |
| @@ -217,7 +218,7 @@ | ||
| 217 | 218 | var target = e.target, |
| 218 | 219 | ev; |
| 219 | 220 | |
| 220 | - if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') { | |
| 221 | + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { | |
| 221 | 222 | ev = document.createEvent('MouseEvents'); |
| 222 | 223 | ev.initMouseEvent('click', true, true, e.view, 1, |
| 223 | 224 | target.screenX, target.screenY, target.clientX, target.clientY, |