Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/86881
Change subject: Fix position fixed handling is iOS <= 4_2
......................................................................
Fix position fixed handling is iOS <= 4_2
Seems to need to account for the height of the address bar
and the open keyboard
Cleanup user agent testing in process
Bug: 53048
Change-Id: I841ca5c6925ff189bd7a9b24e04d645d491dbf1f
---
M javascripts/common/application.js
1 file changed, 21 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/81/86881/1
diff --git a/javascripts/common/application.js
b/javascripts/common/application.js
index de06fd2..2d26219 100644
--- a/javascripts/common/application.js
+++ b/javascripts/common/application.js
@@ -5,6 +5,12 @@
PageApi = M.require( 'PageApi' ),
$viewportMeta, viewport,
template,
+ ua = window.navigator.userAgent,
+ isAppleDevice = /ipad|iphone/i.test( ua ),
+ isIPhone4 = isAppleDevice && /OS 4_/.test( ua ),
+ isIPhone4_2OrOlder = isAppleDevice && /OS [3-4]_[0-2]/.test( ua
),
+ isIPhone5 = isAppleDevice && /OS 5_/.test( ua ),
+ isAndroid2 = /Android 2/.test( ua ),
templates = {};
template = {
@@ -102,7 +108,18 @@
$( window ).on( 'scroll', function() {
var scrollTop = $( window ).scrollTop(),
- scrollBottom = scrollTop + $( window
).height();
+ windowHeight = $( window ).height(),
+ activeElement = document.activeElement,
+ scrollBottom = scrollTop + windowHeight;
+ if ( isIPhone4_2OrOlder ) {
+ // add the height of the open soft
keyboard
+ if ( activeElement.tagName ===
'TEXTAREA' || activeElement.tagName === 'INPUT' ) {
+ scrollBottom -= 120;
+ } else {
+ // add the height of the
address bar
+ scrollBottom += 60;
+ }
+ }
if ( scrollTop === 0 ) {
// special case when we're at the
beginning of the page and many
@@ -128,9 +145,7 @@
// allow disabling of transitions in android ics 4.0.2
function fixBrowserBugs() {
// see http://adactio.com/journal/4470/ (fixed in ios 6)
- var
- ua = navigator.userAgent;
- if( $viewportMeta[0] && ua.match( /iPhone|iPad/i ) &&
ua.match( /OS [4-5]_0/ ) ) {
+ if( $viewportMeta[0] && ( isIPhone4 | isIPhone5 ) ) {
lockViewport();
document.addEventListener( 'gesturestart',
function() {
lockViewport();
@@ -139,7 +154,7 @@
// FIXME: Android 2.x can act weird
// (remove if we drop support for some features on it)
- if ( /Android 2/.test( navigator.userAgent ) ) {
+ if ( isAndroid2 ) {
$body.addClass( 'android2' );
// lock the viewport for this device - too
problematic
lockViewport();
@@ -168,7 +183,7 @@
// don't trust Android 2.x, really
// animations cause textareas to misbehave on it
// (http://stackoverflow.com/a/5734984/365238)
- if ( /Android 2/.test( navigator.userAgent ) ) {
+ if ( isAndroid2 ) {
return false;
}
--
To view, visit https://gerrit.wikimedia.org/r/86881
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I841ca5c6925ff189bd7a9b24e04d645d491dbf1f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits