Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rewrite scroll check to always bail out at some point. Fixes Android4…

…/Nexus S getting stuck in endless check loop. Still keeps it as short as possible by looking for height changes
  • Loading branch information...
commit 87c49c041af744050b7be5f25c3751ae3c132aea 1 parent 62f7034
Jörn Zaefferer jzaefferer authored
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/viewporter.js
18 src/viewporter.js
View
@@ -123,17 +123,23 @@ var viewporter;
window.scrollTo(0, that.IS_ANDROID ? 1 : 0); // Android needs to scroll by at least 1px
// start the checker loop
- var iterations = this.IS_ANDROID && !deviceProfile ? 20 : 5; // if we're on Android and don't know the device, brute force hard
+ var iterations = 40;
var check = window.setInterval(function() {
// retry scrolling
window.scrollTo(0, that.IS_ANDROID ? 1 : 0); // Android needs to scroll by at least 1px
- if(
- that.IS_ANDROID
- ? (deviceProfile ? window.innerHeight === deviceProfile[orientation] : --iterations < 0) // Android: either match against a device profile, or brute force
- : (window.innerHeight > startHeight || --iterations < 0) // iOS is comparably easy!
- ) {
+ function androidProfileCheck() {
+ return deviceProfile ? window.innerHeight === deviceProfile[orientation] : false;
+ }
+ function iosInnerHeightCheck() {
+ return window.innerHeight > startHeight;
+ }
+
+ iterations--;
+
+ // check iterations first to make sure we never get stuck
+ if ( (that.IS_ANDROID ? androidProfileCheck() : iosInnerHeightCheck()) || iterations < 0) {
// set minimum height of content to new window height
document.documentElement.style.minHeight = window.innerHeight + 'px';
Please sign in to comment.
Something went wrong with that request. Please try again.