Merge "Delay scrolling to a heading more on mobile"

This commit is contained in:
jenkins-bot 2014-07-29 20:10:42 +00:00 committed by Gerrit Code Review
commit 7072345c22
2 changed files with 19 additions and 13 deletions

View file

@ -103,10 +103,15 @@ ve.init.mw.MobileViewTarget.prototype.setupToolbar = function () {
/**
* @inheritdoc
*/
ve.init.mw.MobileViewTarget.prototype.scrollTo = function ( position ) {
ve.init.mw.MobileViewTarget.prototype.scrollToHeading = function ( headingNode ) {
var target = this;
if ( this.isIos ) {
this.surface.$element.closest( '.overlay-content' ).scrollTop( position );
setTimeout( function () {
var position = headingNode.$element.offset().top - target.toolbar.$element.height();
target.surface.$element.closest( '.overlay-content' ).scrollTop( position );
}, 400 );
} else {
ve.init.mw.MobileViewTarget.super.prototype.scrollTo.call( this, position );
ve.init.mw.MobileViewTarget.super.prototype.scrollToHeading.call( this, headingNode );
}
};

View file

@ -1434,7 +1434,6 @@ 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,
@ -1468,10 +1467,7 @@ ve.init.mw.Target.prototype.restoreEditSection = function () {
surfaceModel.setSelection( new ve.Range( offset ) );
} );
// Scroll to heading:
// Wait for toolbar to animate in so we can account for its height
setTimeout( function () {
target.scrollTo( headingNode.$element.offset().top - target.toolbar.$element.height() );
}, 200 );
this.scrollToHeading( headingNode );
}
this.section = undefined;
@ -1479,12 +1475,17 @@ ve.init.mw.Target.prototype.restoreEditSection = function () {
};
/**
* Scroll to a given position in the document.
* Scroll to a given heading in the document.
*
* @method
* @param {number} position Position (in pixels) to scroll to
* @param {ve.ce.HeadingNode} headingNode Heading node to scroll to
*/
ve.init.mw.Target.prototype.scrollTo = function ( position ) {
var $window = $( OO.ui.Element.getWindow( this.$element ) );
$window.scrollTop( position );
ve.init.mw.Target.prototype.scrollToHeading = function ( headingNode ) {
var $window = $( OO.ui.Element.getWindow( this.$element ) ),
target = this;
// Wait for toolbar to animate in so we can account for its height
setTimeout( function () {
$window.scrollTop( headingNode.$element.offset().top - target.toolbar.$element.height() );
}, 200 );
};