Delay scrollToHeading() until after the selection is rerendered

Otherwise either the focusing of the surface or the resetting
of the selection seems to cause the viewport to scroll back
up on mobile.

Change-Id: Ie3b104e04800d2753f99739f877c76e334965fc1
This commit is contained in:
Roan Kattouw 2014-07-29 14:58:24 -07:00
parent 7072345c22
commit 859d85257b

View file

@ -1434,6 +1434,7 @@ ve.init.mw.Target.prototype.startSanityCheck = function () {
ve.init.mw.Target.prototype.restoreEditSection = function () {
if ( this.section !== undefined && this.section > 0 ) {
var offset, offsetNode, nextNode,
target = this,
surfaceView = this.surface.getView(),
surfaceModel = surfaceView.getModel(),
$documentNode = surfaceView.getDocument().getDocumentNode().$element,
@ -1465,9 +1466,8 @@ ve.init.mw.Target.prototype.restoreEditSection = function () {
// the model selection, otherwise it will get reset
this.surface.getView().once( 'focus', function () {
surfaceModel.setSelection( new ve.Range( offset ) );
target.scrollToHeading( headingNode );
} );
// Scroll to heading:
this.scrollToHeading( headingNode );
}
this.section = undefined;