mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Improve smooth scroll to section with visual section editing on desktop"
This commit is contained in:
commit
2b5aeaf649
|
@ -463,11 +463,12 @@
|
|||
var offset = 0;
|
||||
var enableVisualSectionEditing = mw.config.get( 'wgVisualEditorConfig' ).enableVisualSectionEditing;
|
||||
if ( enableVisualSectionEditing === true || enableVisualSectionEditing === 'desktop' ) {
|
||||
// Heading will jump to the top of the page in visual section editing
|
||||
// Heading will jump to the top of the page in visual section editing.
|
||||
// This measurement already includes the height of $toolbarPlaceholder.
|
||||
offset = $( '#mw-content-text' ).offset().top;
|
||||
} else {
|
||||
// Align with top of heading margin. Doesn't apply in visual section editing as the margin collapses.
|
||||
offset = parseInt( $heading.css( 'margin-top' ) );
|
||||
offset = parseInt( $heading.css( 'margin-top' ) ) + $toolbarPlaceholder.outerHeight();
|
||||
}
|
||||
|
||||
// Support for CSS `scroll-behavior: smooth;` and JS `window.scroll( { behavior: 'smooth' } )`
|
||||
|
@ -475,7 +476,7 @@
|
|||
// * https://caniuse.com/css-scroll-behavior
|
||||
// * https://caniuse.com/mdn-api_window_scroll_options_behavior_parameter
|
||||
var supportsSmoothScroll = 'scrollBehavior' in document.documentElement.style;
|
||||
var newScrollTop = $heading.offset().top - offset - $toolbarPlaceholder.outerHeight();
|
||||
var newScrollTop = $heading.offset().top - offset;
|
||||
if ( supportsSmoothScroll ) {
|
||||
window.scroll( {
|
||||
top: newScrollTop,
|
||||
|
|
Loading…
Reference in a new issue