[Pkg-javascript-commits] [node-iscroll] 01/09: Imported Upstream version 5.2.0+dfsg1
Balint Reczey
rbalint at moszumanska.debian.org
Mon Aug 1 09:15:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
rbalint pushed a commit to branch master
in repository node-iscroll.
commit 80961b00030c763a85ef71e10679cff11cc93d6c
Author: Balint Reczey <balint at balintreczey.hu>
Date: Mon Aug 1 10:45:20 2016 +0200
Imported Upstream version 5.2.0+dfsg1
---
CONTRIBUTING.md | 18 +--
README.md | 298 +++++++++++++++++++++++----------------
RELEASENOTES.md | 40 +++++-
package.json | 10 +-
src/close.js | 4 +-
src/core.js | 54 +++++--
src/default/handleEvent.js | 2 +-
src/indicator/_initIndicators.js | 6 +-
src/indicator/indicator.js | 30 +++-
src/utils.js | 38 ++++-
src/wheel/wheel.js | 10 +-
11 files changed, 336 insertions(+), 174 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a331488..b855852 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,19 +1,5 @@
# Contributing to iScroll / FAQ
-## Why we need a CLA (Contributor License Agreement)
+You are very welcome to collaborate, all changes to the code will be released under an MIT license.
-All contributions are welcome but to enforce the openness of this script I have to ask all contributors to sign a Contributor License Agreement. I'm sorry about this but it's the only way to keep the script free and Open Source.
-
-If you are an individual, please sign the following form:
-http://cubiq.org/iscroll/cla/individual.html
-
-If you are a company or an entity please sign the following form:
-http://cubiq.org/iscroll/cla/entity.html
-
-## Why is my patch not accepted yet?
-Thank you very much for your contribution. Please make sure you signed the CLA (see above). Please note that pull requests may take some time to be accepted. Testing iScroll is one of the most time consuming tasks of the project. iScroll works from desktop to smartphone, from tablets to smart TVs. I do not have physical access to all the testing devices, so before I can push a change I have to make sure that the new code is working everywhere.
-
-If you want to speed up the process, please provide your own test results and try to be as more specific as possible.
-
-Thanks!
-Matteo Spinelli
\ No newline at end of file
+By submitting a pull request you implicitly agree to give rights of your code to the project authors. Your contribution will always be released under the same MIT license.
diff --git a/README.md b/README.md
index b96f318..370ce4d 100644
--- a/README.md
+++ b/README.md
@@ -37,13 +37,15 @@ Try to keep the DOM as simple as possible. iScroll uses the hardware compositing
The optimal HTML structure is:
- <div id="wrapper">
- <ul>
- <li>...</li>
- <li>...</li>
- ...
- </ul>
- </div>
+```html
+<div id="wrapper">
+ <ul>
+ <li>...</li>
+ <li>...</li>
+ ...
+ </ul>
+</div>
+```
iScroll must be applied to the wrapper of the scrolling area. In the above example the `UL` element will be scrolled. Only the first child of the container element is scrolled, additional children are simply ignored.
@@ -55,18 +57,24 @@ iScroll must be applied to the wrapper of the scrolling area. In the above examp
The minimal call to initiate the script is as follow:
- <script type="text/javascript">
- var myScroll = new IScroll('#wrapper');
- </script>
+```html
+<script type="text/javascript">
+var myScroll = new IScroll('#wrapper');
+</script>
+```
The first parameter can be a string representing the DOM selector of the scroll container element OR a reference to the element itself. The following is a valid syntax too:
- var wrapper = document.getElementById('wrapper');
- var myScroll = new IScroll(wrapper);
+```js
+var wrapper = document.getElementById('wrapper');
+var myScroll = new IScroll(wrapper);
+```
So basically either you pass the element directly or a string that will be given to `querySelector`. Consequently to select a wrapper by its class name instead of the ID, you'd do:
- var myScroll = new IScroll('.wrapper');
+```js
+var myScroll = new IScroll('.wrapper');
+```
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.
@@ -86,26 +94,28 @@ The iScroll needs to be initiated when the DOM is ready. The safest bet is to st
To sum up, the smallest iScroll configuration is:
- <head>
- ...
- <script type="text/javascript" src="iscroll.js"></script>
- <script type="text/javascript">
- var myScroll;
- function loaded() {
- myScroll = new IScroll('#wrapper');
- }
- </script>
- </head>
- ...
- <body onload="loaded()">
- <div id="wrapper">
- <ul>
- <li>...</li>
- <li>...</li>
- ...
- </ul>
- </div>
- </body>
+```html
+<head>
+...
+<script type="text/javascript" src="iscroll.js"></script>
+<script type="text/javascript">
+var myScroll;
+function loaded() {
+ myScroll = new IScroll('#wrapper');
+}
+</script>
+</head>
+...
+<body onload="loaded()">
+<div id="wrapper">
+ <ul>
+ <li>...</li>
+ <li>...</li>
+ ...
+ </ul>
+</div>
+</body>
+```
Refer to the [barebone example](http://lab.cubiq.org/iscroll5/demos/barebone/) for more details on the minimal CSS/HTML requirements.
@@ -117,16 +127,20 @@ Refer to the [barebone example](http://lab.cubiq.org/iscroll5/demos/barebone/) f
iScroll can be configured by passing a second parameter during the initialization phase.
- var myScroll = new IScroll('#wrapper', {
- mouseWheel: true,
- scrollbars: true
- });
+```js
+var myScroll = new IScroll('#wrapper', {
+ mouseWheel: true,
+ scrollbars: true
+});
+```
The example above turns on mouse wheel support and scrollbars.
After initialization you can access the *normalized* values from the `options` object. Eg:
- console.dir(myScroll.options);
+```js
+console.dir(myScroll.options);
+```
The above will return the configuration the `myScroll` instance will run on. By *normalized* I mean that if you set `useTransform:true` (for example) but the browser doesn't support CSS transforms, `useTransform` will be `false`.
@@ -184,10 +198,12 @@ If you have an internal mechanism for device detection or you know in advance wh
For example to disable mouse and pointer events:
- var myScroll = new IScroll('#wrapper', {
- disableMouse: true,
- disablePointer: true
- });
+```js
+var myScroll = new IScroll('#wrapper', {
+ disableMouse: true,
+ disablePointer: true
+});
+```
Default: `false`
@@ -267,12 +283,16 @@ Set this to `true` to let iScroll emit a custom `tap` event when the scroll area
This is the suggested way to handle user interaction with clickable elements. To listen to the tap event you would add an event listener as you would do for a standard event. Example:
- element.addEventListener('tap', doSomething, false); \\ Native
- $('#element').on('tap', doSomething); \\ jQuery
+```js
+element.addEventListener('tap', doSomething, false); \\ Native
+$('#element').on('tap', doSomething); \\ jQuery
+```
You can also customize the event name by passing a string. Eg:
- tap: 'myCustomTapEvent'
+```js
+tap: 'myCustomTapEvent'
+```
In this case you'd listen to `myCustomTapEvent`.
@@ -290,9 +310,11 @@ Let's start with the basis.
As we mentioned in the [Basic features section](#basic-features) there's only one thing that you got to do to activate the scrollbars in all their splendor, and that one thing is:
- var myScroll = new IScroll('#wrapper', {
- scrollbars: true
- });
+```js
+var myScroll = new IScroll('#wrapper', {
+ scrollbars: true
+});
+```
Of course the default behavior can be personalized.
@@ -337,9 +359,11 @@ See the [scrollbar demo](http://lab.cubiq.org/iscroll5/demos/scrollbars/).
So you don't like the default scrollbar styling and you think you could do better. Help yourself! iScroll makes dressing the scrollbar a snap. First of all set the `scrollbars` option to `'custom'`:
- var myScroll = new IScroll('#wrapper', {
- scrollbars: 'custom'
- });
+```js
+var myScroll = new IScroll('#wrapper', {
+ scrollbars: 'custom'
+});
+```
Then use the following CSS classes to style the little bastards.
@@ -358,20 +382,22 @@ Please keep reading to the following section for a revelation that will shake yo
All the scrollbar options above are in reality just wrappers to the low level `indicators` option. It looks more or less like this:
- var myScroll = new IScroll('#wrapper', {
- indicators: {
- el: [element|element selector]
- fade: false,
- ignoreBoundaries: false,
- interactive: false,
- listenX: true,
- listenY: true,
- resize: true,
- shrink: false,
- speedRatioX: 0,
- speedRatioY: 0,
- }
- });
+```js
+var myScroll = new IScroll('#wrapper', {
+ indicators: {
+ el: [element|element selector]
+ fade: false,
+ ignoreBoundaries: false,
+ interactive: false,
+ listenX: true,
+ listenY: true,
+ resize: true,
+ shrink: false,
+ speedRatioX: 0,
+ speedRatioY: 0,
+ }
+});
+```
### <small>options.indicators.</small>el
@@ -379,15 +405,19 @@ This is a mandatory parameter which holds a reference to the scrollbar container
Valid syntax would be:
- indicators: {
- el: document.getElementById('indicator')
- }
+```js
+indicators: {
+ el: document.getElementById('indicator')
+}
+```
Or simply:
- indicators: {
- el: '#indicator'
- }
+```js
+indicators: {
+ el: '#indicator'
+}
+```
### <small>options.indicators.</small>ignoreBoundaries
@@ -435,7 +465,9 @@ You silly! Of course you can scroll programmaticaly!
Say your iScroll instance resides into the `myScroll` variable. You can easily scroll to any position with the following syntax:
- myScroll.scrollTo(0, -100);
+```js
+myScroll.scrollTo(0, -100);
+```
That would scroll down by 100 pixels. Remember: 0 is always the top left corner. To scroll you have to pass negative numbers.
@@ -443,7 +475,9 @@ That would scroll down by 100 pixels. Remember: 0 is always the top left corner.
The easing functions are available in the `IScroll.utils.ease` object. For example to apply a 1 second elastic easing you'd do:
- myScroll.scrollTo(0, -100, 1000, IScroll.utils.ease.elastic);
+```js
+myScroll.scrollTo(0, -100, 1000, IScroll.utils.ease.elastic);
+```
The available options are: `quadratic`, `circular`, `back`, `bounce`, `elastic`.
@@ -451,7 +485,9 @@ The available options are: `quadratic`, `circular`, `back`, `bounce`, `elastic`.
Same as above but X and Y are relative to the current position.
- myScroll.scrollBy(0, -10);
+```js
+myScroll.scrollBy(0, -10);
+```
Would scroll 10 pixels down. If you are at -100, you'll end up at -110.
@@ -475,17 +511,21 @@ iScroll can snap to fixed positions and elements.
The simplest snap config is as follow:
- var myScroll = new IScroll('#wrapper', {
- snap: true
- });
+```js
+var myScroll = new IScroll('#wrapper', {
+ snap: true
+});
+```
This would automatically split the scroller into pages the size of the container.
`snap` also takes a string as a value. The string will be the selector to the elements the scroller will be snapped to. So the following
- var myScroll = new IScroll('#wrapper', {
- snap: 'li'
- });
+```js
+var myScroll = new IScroll('#wrapper', {
+ snap: 'li'
+});
+```
would snap to each and every `LI` tag.
@@ -497,7 +537,9 @@ To help you navigate through the snap points iScroll grants access to a series o
`time` is the duration of the animation, `easing` the easing function used to scroll to the point. Refer to the **option.bounceEasing** in the [Advanced features](#advanced-features). They are both optional.
- myScroll.goToPage(10, 0, 1000);
+```js
+myScroll.goToPage(10, 0, 1000);
+```
This would scroll to the 10th page on the horizontal axis in 1 second.
@@ -527,7 +569,7 @@ Minimum zoom level.
Default: `1`
-### <small>options.</small>zoomStart
+### <small>options.</small>startZoom
Starting zoom level.
@@ -541,11 +583,13 @@ Default: `undefined` (ie: the mouse wheel scrolls)
To sum up, a nice zoom config would be:
- myScroll = new IScroll('#wrapper', {
- zoom: true,
- mouseWheel: true,
- wheelAction: 'zoom'
- });
+```js
+myScroll = new IScroll('#wrapper', {
+ zoom: true,
+ mouseWheel: true,
+ wheelAction: 'zoom'
+});
+```
<div class="important">
<p>The zoom is performed with CSS transform. iScroll can zoom only on browsers that support that.</p>
@@ -595,10 +639,12 @@ Easing function performed during the bounce animation. Valid values are: `'quadr
`bounceEasing` is a bit smarter than that. You can also feed a custom easing function, like so:
- bounceEasing: {
- style: 'cubic-bezier(0,0,1,1)',
- fn: function (k) { return k; }
- }
+```js
+bounceEasing: {
+ style: 'cubic-bezier(0,0,1,1)',
+ fn: function (k) { return k; }
+}
+```
The above would perform a linear easing. The `style` option is used every time the animation is executed with CSS transitions, `fn` is used with `requestAnimationFrame`. If the easing function is too complex and can't be represented by a cubic bezier just pass `''` (empty string) as `style`.
@@ -630,7 +676,9 @@ These are all the exceptions when `preventDefault()` would be fired anyway despi
This is a pretty powerful option, if you don't want to `preventDefault()` on all elements with *formfield* class name for example, you could pass the following:
- preventDefaultException: { className: /(^|\s)formfield(\s|$)/ }
+```js
+preventDefaultException: { className: /(^|\s)formfield(\s|$)/ }
+```
Default: `{ tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ }`.
@@ -652,15 +700,17 @@ Every time you touch the DOM the browser renderer repaints the page. Once this r
To ensure that javascript gets the updated properties you should defer the refreh with something like this:
- ajax('page.php', onCompletion);
+```js
+ajax('page.php', onCompletion);
- function onCompletion () {
- // Update here your DOM
-
- setTimeout(function () {
- myScroll.refresh();
- }, 0);
- };
+function onCompletion () {
+ // Update here your DOM
+
+ setTimeout(function () {
+ myScroll.refresh();
+ }, 0);
+};
+```
We have placed the `refresh()` call into a zero timeout. That is likely all you need to correctly refresh the iScroll boundaries. There are other ways to wait for the repaint, but the zero-timeout has proven pretty solid.
@@ -676,8 +726,10 @@ iScroll also emits some useful custom events you can hook to.
To register them you use the `on(type, fn)` method.
- myScroll = new IScroll('#wrapper');
- myScroll.on('scrollEnd', doSomething);
+```js
+myScroll = new IScroll('#wrapper');
+myScroll.on('scrollEnd', doSomething);
+```
The above code executes the `doSomething` function every time the content stops scrolling.
@@ -716,16 +768,18 @@ You can pass an object with the list of key codes you want iScroll to react to.
The default values are as follow:
- keyBindings: {
- pageUp: 33,
- pageDown: 34,
- end: 35,
- home: 36,
- left: 37,
- up: 38,
- right: 39,
- down: 40
- }
+```js
+keyBindings: {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+}
+```
You can also pass a string (eg: `pageUp: 'a'`) and iScroll will convert it for you. You could just think of a key code and iScroll would read it out of your mind.
@@ -741,12 +795,14 @@ You will probably find useful:
These pieces of information may be useful when dealing with custom events. Eg:
- myScroll = new IScroll('#wrapper');
- myScroll.on('scrollEnd', function () {
- if ( this.x < -1000 ) {
- // do something
- }
- });
+```js
+myScroll = new IScroll('#wrapper');
+myScroll.on('scrollEnd', function () {
+ if ( this.x < -1000 ) {
+ // do something
+ }
+});
+```
The above executes some code if the `x` position is lower than -1000px when the scroller stops. Note that I used `this` instead of `myScroll`, you can use both of course, but iScroll passes itself as `this` context when firing custom event functions.
@@ -754,8 +810,10 @@ The above executes some code if the `x` position is lower than -1000px when the
The public `destroy()` method can be used to free some memory when the iScroll is not needed anymore.
- myScroll.destroy();
- myScroll = null;
+```js
+myScroll.destroy();
+myScroll = null;
+```
<h2 id="contributing">Contributing and CLA</h2>
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 4e18129..b806df8 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -2,10 +2,46 @@
---
+## Version 5.2.0 - 2016.04.05
+
+### Fixes
+* Fixes weird scrolling in Chrome (#760, #441, #943, #927, #780)
+* [#1009](https://github.com/cubiq/iscroll/issues/1009) fixes utils.prefixPointerEvent method
+* [#1018](https://github.com/cubiq/iscroll/issues/1018), [#652](https://github.com/cubiq/iscroll/issues/652) fixes directionX/Y when scrolling with mouse
+* [#924](https://github.com/cubiq/iscroll/issues/924), [#950](https://github.com/cubiq/iscroll/issues/950) clean up timer on destroy
+* [#949](https://github.com/cubiq/iscroll/issues/949) removes unnecesary style values on wrapper when useTransition option is 'false'
+* [#361](https://github.com/cubiq/iscroll/issues/361) fixes two click/tap events issue
+* [#980](https://github.com/cubiq/iscroll/issues/980) fixes event propagation for wheel event
+* [#768](https://github.com/cubiq/iscroll/issues/768) fixes indicators
+* [#761](https://github.com/cubiq/iscroll/issues/761) fixes two scrollEnd events issue
+* Fixes 'click' event is not fired when iScroll is disabled
+
+### Changes
+* Added AMD support
+* Changed default value of disableMouse/disableTouch/disablePointer options
+* Removed CLA non-sense
+
+---
+
+## Version 5.1.3 - 2014.09.19
+
+### Fixes
+* [#577](https://github.com/cubiq/iscroll/issues/577) fixes scrolling in Firefox
+
+---
+
+## Version 5.1.2 - 2014.06.02
+
+### Fixes
+* [#707](https://github.com/cubiq/iscroll/pull/707) fixes build fail when dist folder does not exist
+* [#713](https://github.com/cubiq/iscroll/pull/713) Adds W3C pointer support and fixes issue with `MSPointerEvent` detection
+
+---
+
## Version 5.1.1 - 2014.01.10
### Fixes
-* Infinite scroll now switch from `transform` to `top/left` based on `useTransform` option.
+* Infinite scroll now switch from `transform` to `top/left` based on `useTransform` option
* [#555](https://github.com/cubiq/iscroll/issues/555) removed unused variable
* [#372](https://github.com/cubiq/iscroll/issues/372) case insensitive check on tag names
@@ -31,4 +67,4 @@
---
-*I started collecting release notes from version 5.1.0*
\ No newline at end of file
+*I started collecting release notes from version 5.1.0*
diff --git a/package.json b/package.json
index 90be17e..60a4244 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
{
"name": "iscroll",
"description": "Smooth scrolling for the web",
- "version": "5.1.3",
- "homepage": "http://cubiq.org/iscroll-4",
+ "version": "5.2.0",
+ "homepage": "http://iscrolljs.com",
"author": "Matteo Spinelli <matteo at cubiq.org> (http://cubiq.org)",
"keywords": [
"scrolling",
@@ -15,8 +15,8 @@
],
"main": "build/iscroll.js",
"devDependencies": {
- "jshint": "~2.5.1",
- "uglify-js": "~2.4.13"
+ "jshint": "~2.9.1",
+ "uglify-js": "~2.6.2"
},
"repository": {
"type": "git",
@@ -26,4 +26,4 @@
"url": "https://github.com/cubiq/iscroll/issues"
},
"license": "MIT"
-}
\ No newline at end of file
+}
diff --git a/src/close.js b/src/close.js
index 1523cf2..6c8546f 100644
--- a/src/close.js
+++ b/src/close.js
@@ -3,8 +3,10 @@ IScroll.utils = utils;
if ( typeof module != 'undefined' && module.exports ) {
module.exports = IScroll;
+} else if ( typeof define == 'function' && define.amd ) {
+ define( function () { return IScroll; } );
} else {
window.IScroll = IScroll;
}
-})(window, document, Math);
\ No newline at end of file
+})(window, document, Math);
diff --git a/src/core.js b/src/core.js
index dcfab62..300c064 100644
--- a/src/core.js
+++ b/src/core.js
@@ -6,8 +6,10 @@ function IScroll (el, options) {
this.options = {
-// INSERT POINT: OPTIONS
-
+// INSERT POINT: OPTIONS
+ disablePointer : !utils.hasPointer,
+ disableTouch : utils.hasPointer || !utils.hasTouch,
+ disableMouse : utils.hasPointer || utils.hasTouch,
startX: 0,
startY: 0,
scrollY: true,
@@ -23,7 +25,8 @@ function IScroll (el, options) {
HWCompositing: true,
useTransition: true,
- useTransform: true
+ useTransform: true,
+ bindToWrapper: typeof window.onmousedown === "undefined"
};
for ( var i in options ) {
@@ -57,7 +60,7 @@ function IScroll (el, options) {
// INSERT POINT: NORMALIZATION
- // Some defaults
+ // Some defaults
this.x = 0;
this.y = 0;
this.directionX = 0;
@@ -85,7 +88,8 @@ IScroll.prototype = {
destroy: function () {
this._initEvents(true);
-
+ clearTimeout(this.resizeTimeout);
+ this.resizeTimeout = null;
this._execEvent('destroy');
},
@@ -104,7 +108,18 @@ IScroll.prototype = {
_start: function (e) {
// React to left mouse button only
if ( utils.eventType[e.type] != 1 ) {
- if ( e.button !== 0 ) {
+ // for button property
+ // http://unixpapa.com/js/mouse.html
+ var button;
+ if (!e.which) {
+ /* IE case */
+ button = (e.button < 2) ? 0 :
+ ((e.button == 4) ? 1 : 2);
+ } else {
+ /* All others */
+ button = e.button;
+ }
+ if ( button !== 0 ) {
return;
}
}
@@ -128,11 +143,10 @@ IScroll.prototype = {
this.directionY = 0;
this.directionLocked = 0;
- this._transitionTime();
-
this.startTime = utils.getTime();
if ( this.options.useTransition && this.isInTransition ) {
+ this._transitionTime();
this.isInTransition = false;
pos = this.getComputedPosition();
this._translate(Math.round(pos.x), Math.round(pos.y));
@@ -461,10 +475,12 @@ IScroll.prototype = {
easing = easing || utils.ease.circular;
this.isInTransition = this.options.useTransition && time > 0;
-
- if ( !time || (this.options.useTransition && easing.style) ) {
- this._transitionTimingFunction(easing.style);
- this._transitionTime(time);
+ var transitionType = this.options.useTransition && easing.style;
+ if ( !time || transitionType ) {
+ if(transitionType) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ }
this._translate(x, y);
} else {
this._animate(x, y, time, easing.fn);
@@ -505,10 +521,18 @@ IScroll.prototype = {
_transitionTime: function (time) {
time = time || 0;
- this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+ var durationProp = utils.style.transitionDuration;
+ this.scrollerStyle[durationProp] = time + 'ms';
if ( !time && utils.isBadAndroid ) {
- this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ this.scrollerStyle[durationProp] = '0.0001ms';
+ // remove 0.0001ms
+ var self = this;
+ rAF(function() {
+ if(self.scrollerStyle[durationProp] === '0.0001ms') {
+ self.scrollerStyle[durationProp] = '0s';
+ }
+ });
}
// INSERT POINT: _transitionTime
@@ -597,4 +621,4 @@ IScroll.prototype = {
}
return { x: x, y: y };
- },
+ },
\ No newline at end of file
diff --git a/src/default/handleEvent.js b/src/default/handleEvent.js
index 864ede1..c27288f 100644
--- a/src/default/handleEvent.js
+++ b/src/default/handleEvent.js
@@ -42,7 +42,7 @@
this._key(e);
break;
case 'click':
- if ( !e._constructed ) {
+ if ( this.enabled && !e._constructed ) {
e.preventDefault();
e.stopPropagation();
}
diff --git a/src/indicator/_initIndicators.js b/src/indicator/_initIndicators.js
index 492d56c..20b199f 100644
--- a/src/indicator/_initIndicators.js
+++ b/src/indicator/_initIndicators.js
@@ -56,8 +56,10 @@
// TODO: check if we can use array.map (wide compatibility and performance issues)
function _indicatorsMap (fn) {
- for ( var i = that.indicators.length; i--; ) {
- fn.call(that.indicators[i]);
+ if (that.indicators) {
+ for ( var i = that.indicators.length; i--; ) {
+ fn.call(that.indicators[i]);
+ }
}
}
diff --git a/src/indicator/indicator.js b/src/indicator/indicator.js
index 8c6eb77..48a4cb9 100644
--- a/src/indicator/indicator.js
+++ b/src/indicator/indicator.js
@@ -80,7 +80,17 @@ function Indicator (scroller, options) {
if ( this.options.fade ) {
this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
- this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
+ var durationProp = utils.style.transitionDuration;
+ this.wrapperStyle[durationProp] = utils.isBadAndroid ? '0.0001ms' : '0ms';
+ // remove 0.0001ms
+ var self = this;
+ if(utils.isBadAndroid) {
+ rAF(function() {
+ if(self.wrapperStyle[durationProp] === '0.0001ms') {
+ self.wrapperStyle[durationProp] = '0s';
+ }
+ });
+ }
this.wrapperStyle.opacity = '0';
}
}
@@ -114,6 +124,10 @@ Indicator.prototype = {
},
destroy: function () {
+ if ( this.options.fadeScrollbars ) {
+ clearTimeout(this.fadeTimeout);
+ this.fadeTimeout = null;
+ }
if ( this.options.interactive ) {
utils.removeEvent(this.indicator, 'touchstart', this);
utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
@@ -228,10 +242,18 @@ Indicator.prototype = {
transitionTime: function (time) {
time = time || 0;
- this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
+ var durationProp = utils.style.transitionDuration;
+ this.indicatorStyle[durationProp] = time + 'ms';
if ( !time && utils.isBadAndroid ) {
- this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
+ this.indicatorStyle[durationProp] = '0.0001ms';
+ // remove 0.0001ms
+ var self = this;
+ rAF(function() {
+ if(self.indicatorStyle[durationProp] === '0.0001ms') {
+ self.indicatorStyle[durationProp] = '0s';
+ }
+ });
}
},
@@ -295,7 +317,7 @@ Indicator.prototype = {
this.maxBoundaryX = this.maxPosX;
}
- this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
+ this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
}
if ( this.options.listenY ) {
diff --git a/src/utils.js b/src/utils.js
index 135da5a..6fcd25e 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -46,8 +46,8 @@ var utils = (function () {
};
me.prefixPointerEvent = function (pointerEvent) {
- return window.MSPointerEvent ?
- 'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
+ return window.MSPointerEvent ?
+ 'MSPointer' + pointerEvent.charAt(7).toUpperCase() + pointerEvent.substr(8):
pointerEvent;
};
@@ -84,12 +84,38 @@ var utils = (function () {
hasTransform: _transform !== false,
hasPerspective: _prefixStyle('perspective') in _elementStyle,
hasTouch: 'ontouchstart' in window,
- hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
+ hasPointer: !!(window.PointerEvent || window.MSPointerEvent), // IE10 is prefixed
hasTransition: _prefixStyle('transition') in _elementStyle
});
- // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
- me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+ /*
+ This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ - galaxy S2 is ok
+ - 2.3.6 : `AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1`
+ - 4.0.4 : `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
+ - galaxy S3 is badAndroid (stock brower, webview)
+ `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
+ - galaxy S4 is badAndroid (stock brower, webview)
+ `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
+ - galaxy S5 is OK
+ `AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
+ - galaxy S6 is OK
+ `AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
+ */
+ me.isBadAndroid = (function() {
+ var appVersion = window.navigator.appVersion;
+ // Android browser is not a chrome browser.
+ if (/Android/.test(appVersion) && !(/Chrome\/\d/.test(appVersion))) {
+ var safariVersion = appVersion.match(/Safari\/(\d+.\d)/);
+ if(safariVersion && typeof safariVersion === "object" && safariVersion.length >= 2) {
+ return parseFloat(safariVersion[1]) < 535.19;
+ } else {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ })();
me.extend(me.style = {}, {
transform: _transform,
@@ -241,4 +267,4 @@ var utils = (function () {
};
return me;
-})();
+})();
\ No newline at end of file
diff --git a/src/wheel/wheel.js b/src/wheel/wheel.js
index ce37a20..8c0a445 100644
--- a/src/wheel/wheel.js
+++ b/src/wheel/wheel.js
@@ -5,6 +5,8 @@
utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
this.on('destroy', function () {
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = null;
utils.removeEvent(this.wrapper, 'wheel', this);
utils.removeEvent(this.wrapper, 'mousewheel', this);
utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
@@ -17,7 +19,6 @@
}
e.preventDefault();
- e.stopPropagation();
var wheelDeltaX, wheelDeltaY,
newX, newY,
@@ -30,7 +31,9 @@
// Execute the scrollEnd event after 400ms the wheel stopped scrolling
clearTimeout(this.wheelTimeout);
this.wheelTimeout = setTimeout(function () {
- that._execEvent('scrollEnd');
+ if(!that.options.snap) {
+ that._execEvent('scrollEnd');
+ }
that.wheelTimeout = undefined;
}, 400);
@@ -85,6 +88,9 @@
newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
+ this.directionX = wheelDeltaX > 0 ? -1 : wheelDeltaX < 0 ? 1 : 0;
+ this.directionY = wheelDeltaY > 0 ? -1 : wheelDeltaY < 0 ? 1 : 0;
+
if ( newX > 0 ) {
newX = 0;
} else if ( newX < this.maxScrollX ) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-iscroll.git
More information about the Pkg-javascript-commits
mailing list