Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/230093

Change subject: Fix toolbar position in iOS
......................................................................

Fix toolbar position in iOS

When the CE is focused in iOS it calculates the overlap between
the desired cursor position and the keyboard, and it scrolls the
window up by that amount.

The problem is the window contains just the toolbar and a scrollable
container, so we end up losing the toolbar.

To work around this, wait for the keyboard to appear then apply
the window's scroll offset to the scrollable container and
reset the window scroll offset to 0.

Change-Id: Ib4ff64589d299cac53a7d12f2a97dfc3149ea65a
---
M resources/mobile.editor.ve/ve.init.mw.MobileFrontendArticleTarget.js
1 file changed, 24 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/93/230093/1

diff --git 
a/resources/mobile.editor.ve/ve.init.mw.MobileFrontendArticleTarget.js 
b/resources/mobile.editor.ve/ve.init.mw.MobileFrontendArticleTarget.js
index 239dce0..bc8205b 100644
--- a/resources/mobile.editor.ve/ve.init.mw.MobileFrontendArticleTarget.js
+++ b/resources/mobile.editor.ve/ve.init.mw.MobileFrontendArticleTarget.js
@@ -5,7 +5,7 @@
  * @license The MIT License (MIT); see LICENSE.txt
  */
 
-/* global ve */
+/* global ve, $ */
 
 // jscs:disable
 
@@ -24,6 +24,7 @@
        ve.init.mw.MobileFrontendArticleTarget.super.call( this, config );
 
        this.overlay = overlay;
+       this.$overlayContent = overlay.$el.find( '.overlay-content' );
        this.$overlaySurface = overlay.$el.find( '.surface' );
 
        // Initialization
@@ -41,6 +42,28 @@
 /*
  * FIXME: @inheritdoc once this file is in the right repo
  */
+ve.init.mw.MobileFrontendArticleTarget.prototype.onSurfaceFocus = function () {
+       // Parent method
+       
ve.init.mw.MobileFrontendArticleTarget.super.prototype.onSurfaceFocus.call( 
this );
+
+       var target = this;
+       if ( ve.init.platform.constructor.static.isIos() ) {
+               // Wait until after the iOS keyboard opening transition
+               setTimeout( function () {
+                       // iOS applies a scroll offset to the window to move 
the cursor
+                       // into view. Apply this offset to the surface instead.
+                       var windowTop = $( window ).scrollTop(),
+                               contentTop = target.$overlayContent.scrollTop();
+
+                       $( window ).scrollTop( 0 );
+                       target.$overlayContent.scrollTop( contentTop + 
windowTop );
+               }, 500 );
+       }
+};
+
+/*
+ * FIXME: @inheritdoc once this file is in the right repo
+ */
 ve.init.mw.MobileFrontendArticleTarget.prototype.createSurface = function ( 
dmDoc, config ) {
        if ( this.overlay.isNewPage ) {
                config = ve.extendObject( {

-- 
To view, visit https://gerrit.wikimedia.org/r/230093
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib4ff64589d299cac53a7d12f2a97dfc3149ea65a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to