mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Scroll to correct offset after using a section edit link
Needs to wait 200ms so it account for toolbar height. Bug: 49563 Change-Id: I3a57e64f54289a3263814b4fbfe00c63de4a490b
This commit is contained in:
parent
2352613b66
commit
1889495aa2
|
@ -1877,15 +1877,23 @@ ve.init.mw.ViewPageTarget.prototype.saveEditSection = function ( heading ) {
|
|||
ve.init.mw.ViewPageTarget.prototype.restoreEditSection = function () {
|
||||
if ( this.section !== null ) {
|
||||
var offset,
|
||||
target = this,
|
||||
surfaceView = this.surface.getView(),
|
||||
surfaceModel = surfaceView.getModel();
|
||||
this.$document.find( 'h1, h2, h3, h4, h5, h6' ).eq( this.section - 1 ).each( function () {
|
||||
var headingNode = $( this ).data( 'view' );
|
||||
|
||||
if ( headingNode ) {
|
||||
offset = surfaceModel.getDocument().data.getNearestContentOffset(
|
||||
headingNode.getModel().getOffset()
|
||||
);
|
||||
surfaceModel.change( null, new ve.Range( offset, offset ) );
|
||||
// Scroll to heading:
|
||||
// Wait for toolbar to animate in so we can account for its height
|
||||
setTimeout( function () {
|
||||
var $window = $( ve.Element.static.getWindow( target.$ ) );
|
||||
$window.scrollTop( headingNode.$.offset().top - target.toolbar.$.height() );
|
||||
}, 200 );
|
||||
}
|
||||
} );
|
||||
this.section = null;
|
||||
|
|
Loading…
Reference in a new issue