Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Commit

Permalink
fix for Android < 4.2.2 (#441 #472)
Browse files Browse the repository at this point in the history
  • Loading branch information
cubiq committed Dec 6, 2013
1 parent 052c5ba commit 626ae38
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 38 deletions.
16 changes: 11 additions & 5 deletions build/iscroll-lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ var utils = (function () {
hasTransition: _prefixStyle('transition') in _elementStyle
});

me.isAndroidBrowser = /Android/.test(window.navigator.appVersion) && /Version\/\d/.test(window.navigator.appVersion);
// 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));

me.extend(me.style = {}, {
transform: _transform,
Expand Down Expand Up @@ -323,11 +324,11 @@ IScroll.prototype = {
},

_transitionEnd: function (e) {
if ( e.target != this.scroller ) {
if ( e.target != this.scroller || !this.isInTransition ) {
return;
}

this._transitionTime(0);
this._transitionTime();
if ( !this.resetPosition(this.options.bounceTime) ) {
this._execEvent('scrollEnd');
}
Expand All @@ -345,8 +346,8 @@ IScroll.prototype = {
return;
}

if ( this.options.preventDefault && !utils.isAndroidBrowser && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault(); // This seems to break default Android browser
if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}

var point = e.touches ? e.touches[0] : e,
Expand Down Expand Up @@ -720,8 +721,13 @@ IScroll.prototype = {

_transitionTime: function (time) {
time = time || 0;

this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';

if ( !time && utils.isBadAndroid ) {
this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
}

// INSERT POINT: _transitionTime

},
Expand Down
24 changes: 17 additions & 7 deletions build/iscroll-probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ var utils = (function () {
hasTransition: _prefixStyle('transition') in _elementStyle
});

me.isAndroidBrowser = /Android/.test(window.navigator.appVersion) && /Version\/\d/.test(window.navigator.appVersion);
// 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));

me.extend(me.style = {}, {
transform: _transform,
Expand Down Expand Up @@ -350,11 +351,11 @@ IScroll.prototype = {
},

_transitionEnd: function (e) {
if ( e.target != this.scroller ) {
if ( e.target != this.scroller || !this.isInTransition ) {
return;
}

this._transitionTime(0);
this._transitionTime();
if ( !this.resetPosition(this.options.bounceTime) ) {
this._execEvent('scrollEnd');
}
Expand All @@ -372,8 +373,8 @@ IScroll.prototype = {
return;
}

if ( this.options.preventDefault && !utils.isAndroidBrowser && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault(); // This seems to break default Android browser
if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}

var point = e.touches ? e.touches[0] : e,
Expand Down Expand Up @@ -770,8 +771,13 @@ IScroll.prototype = {

_transitionTime: function (time) {
time = time || 0;

this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';

if ( !time && utils.isBadAndroid ) {
this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
}


if ( this.indicators ) {
for ( var i = this.indicators.length; i--; ) {
Expand Down Expand Up @@ -1627,7 +1633,7 @@ Indicator.prototype = {
e.preventDefault();
e.stopPropagation();

this.transitionTime(0);
this.transitionTime();

this.initiated = true;
this.moved = false;
Expand Down Expand Up @@ -1715,14 +1721,18 @@ Indicator.prototype = {
transitionTime: function (time) {
time = time || 0;
this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';

if ( !time && utils.isBadAndroid ) {
this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
}
},

transitionTimingFunction: function (easing) {
this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
},

refresh: function () {
this.transitionTime(0);
this.transitionTime();

if ( this.options.listenX && !this.options.listenY ) {
this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
Expand Down
24 changes: 17 additions & 7 deletions build/iscroll-zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ var utils = (function () {
hasTransition: _prefixStyle('transition') in _elementStyle
});

me.isAndroidBrowser = /Android/.test(window.navigator.appVersion) && /Version\/\d/.test(window.navigator.appVersion);
// 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));

me.extend(me.style = {}, {
transform: _transform,
Expand Down Expand Up @@ -356,11 +357,11 @@ IScroll.prototype = {
},

_transitionEnd: function (e) {
if ( e.target != this.scroller ) {
if ( e.target != this.scroller || !this.isInTransition ) {
return;
}

this._transitionTime(0);
this._transitionTime();
if ( !this.resetPosition(this.options.bounceTime) ) {
this._execEvent('scrollEnd');
}
Expand All @@ -378,8 +379,8 @@ IScroll.prototype = {
return;
}

if ( this.options.preventDefault && !utils.isAndroidBrowser && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault(); // This seems to break default Android browser
if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}

var point = e.touches ? e.touches[0] : e,
Expand Down Expand Up @@ -768,8 +769,13 @@ IScroll.prototype = {

_transitionTime: function (time) {
time = time || 0;

this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';

if ( !time && utils.isBadAndroid ) {
this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
}


if ( this.indicators ) {
for ( var i = this.indicators.length; i--; ) {
Expand Down Expand Up @@ -1791,7 +1797,7 @@ Indicator.prototype = {
e.preventDefault();
e.stopPropagation();

this.transitionTime(0);
this.transitionTime();

this.initiated = true;
this.moved = false;
Expand Down Expand Up @@ -1879,14 +1885,18 @@ Indicator.prototype = {
transitionTime: function (time) {
time = time || 0;
this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';

if ( !time && utils.isBadAndroid ) {
this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
}
},

transitionTimingFunction: function (easing) {
this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
},

refresh: function () {
this.transitionTime(0);
this.transitionTime();

if ( this.options.listenX && !this.options.listenY ) {
this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
Expand Down
24 changes: 17 additions & 7 deletions build/iscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ var utils = (function () {
hasTransition: _prefixStyle('transition') in _elementStyle
});

me.isAndroidBrowser = /Android/.test(window.navigator.appVersion) && /Version\/\d/.test(window.navigator.appVersion);
// 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));

me.extend(me.style = {}, {
transform: _transform,
Expand Down Expand Up @@ -347,11 +348,11 @@ IScroll.prototype = {
},

_transitionEnd: function (e) {
if ( e.target != this.scroller ) {
if ( e.target != this.scroller || !this.isInTransition ) {
return;
}

this._transitionTime(0);
this._transitionTime();
if ( !this.resetPosition(this.options.bounceTime) ) {
this._execEvent('scrollEnd');
}
Expand All @@ -369,8 +370,8 @@ IScroll.prototype = {
return;
}

if ( this.options.preventDefault && !utils.isAndroidBrowser && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault(); // This seems to break default Android browser
if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}

var point = e.touches ? e.touches[0] : e,
Expand Down Expand Up @@ -761,8 +762,13 @@ IScroll.prototype = {

_transitionTime: function (time) {
time = time || 0;

this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';

if ( !time && utils.isBadAndroid ) {
this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
}


if ( this.indicators ) {
for ( var i = this.indicators.length; i--; ) {
Expand Down Expand Up @@ -1609,7 +1615,7 @@ Indicator.prototype = {
e.preventDefault();
e.stopPropagation();

this.transitionTime(0);
this.transitionTime();

this.initiated = true;
this.moved = false;
Expand Down Expand Up @@ -1697,14 +1703,18 @@ Indicator.prototype = {
transitionTime: function (time) {
time = time || 0;
this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';

if ( !time && utils.isBadAndroid ) {
this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
}
},

transitionTimingFunction: function (easing) {
this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
},

refresh: function () {
this.transitionTime(0);
this.transitionTime();

if ( this.options.listenX && !this.options.listenY ) {
this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
Expand Down
Loading

0 comments on commit 626ae38

Please sign in to comment.