mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Fix section scrolling
Core code now has a scrollIntoView animation triggered on focus which needs to be cancelled before we scroll to the section heading. Change-Id: I5eb6a5c98b38c2510d2d7f0108fe56e607b34bd6
This commit is contained in:
parent
7a33613d23
commit
be5df39f5b
|
@ -1347,7 +1347,9 @@ ve.init.mw.Target.prototype.goToHeading = function ( headingNode ) {
|
|||
var nextNode, offset,
|
||||
target = this,
|
||||
offsetNode = headingNode,
|
||||
surfaceModel = this.getSurface().getView().getModel(),
|
||||
surface = this.getSurface(),
|
||||
surfaceModel = surface.getModel(),
|
||||
surfaceView = surface.getView(),
|
||||
lastHeadingLevel = -1;
|
||||
|
||||
// Find next sibling which isn't a heading
|
||||
|
@ -1365,8 +1367,11 @@ ve.init.mw.Target.prototype.goToHeading = function ( headingNode ) {
|
|||
);
|
||||
// onDocumentFocus is debounced, so wait for that to happen before setting
|
||||
// the model selection, otherwise it will get reset
|
||||
this.getSurface().getView().once( 'focus', function () {
|
||||
surfaceView.once( 'focus', function () {
|
||||
surfaceModel.setLinearSelection( new ve.Range( offset ) );
|
||||
// Focussing the document triggers showSelection which calls scrollIntoView
|
||||
// which uses a jQuery animation, so make sure this is aborted.
|
||||
$( OO.ui.Element.static.getClosestScrollableContainer( surfaceView.$element[0] ) ).stop( true );
|
||||
target.scrollToHeading( headingNode );
|
||||
} );
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue