ve.init.mw.MobileArticleTarget: Remove code causing scrolling issues

This code is supposed to check if we have scrolled past the end of the
page, and if we did, scroll back up to a more reasonable position.

However, it seems to incorrectly trigger in other cases, and scroll
the page back to the top, because getBoundingClientRect() occasionally
still returns bogus values (even though we try to avoid that). This
happens inconsistently when focussing the surface or closing a dialog.

We can't correctly display the toolbar while scrolled past the end of
the page. Removing this code causes it to go into an endless animation
loop in that case. But that may be preferable…

Bug: T219200
Change-Id: I152f2b39351ffd3c9799eea33cce95e05d2f9ab9
This commit is contained in:
Bartosz Dziewoński 2019-03-29 02:16:40 +01:00
parent 2455b94f18
commit 17a0b407fc

View file

@ -191,26 +191,11 @@ ve.init.mw.MobileArticleTarget.prototype.onContainerScroll = function () {
$overlaySurface.css( 'transform', '' );
document.body.scrollTop = scrollPos;
this.onContainerScrollTimer = setTimeout( function () {
// Recheck, because weird things happen when you scroll to the bottom of the page.
// window.innerHeight *actually changes to accomodate the keyboard*, like it should, except
// it is off by a few pixels so we can't actually use it, and also nothing else in the
// browser seems to be aware of that, so positioning puts our toolbar offscreen again.
pos = $header[ 0 ].getBoundingClientRect().top - headerTranslateY;
if ( pos < -1 ) {
// `pos` is negative, so this scrolls up
$( document.body ).animate( { scrollTop: scrollPos + pos }, 250 );
}
// Animate toolbar sliding into view
$header.addClass( 'toolbar-shown' ).css( 'transform', '' );
setTimeout( function () {
$header.addClass( 'toolbar-shown-done' );
}, 250 );
// There has to be a delay here as well. If this is 0, then the getBoundingClientRect call
// returns bogus values and we scroll crazily all over the place.
}, 50 );
// Animate toolbar sliding into view
$header.addClass( 'toolbar-shown' ).css( 'transform', '' );
setTimeout( function () {
$header.addClass( 'toolbar-shown-done' );
}, 250 );
} );
}, 250 );
};