mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Scroll below sticky header only if sticky header is present
Bug: T312926 Change-Id: Ide45141f0a21b782f8674ecbed9ee512de985661
This commit is contained in:
parent
2f555569ea
commit
800461efac
|
@ -15,6 +15,7 @@
|
|||
* @param {Object} config
|
||||
* @cfg {ve.ui.MWTransclusionOutlineParameterWidget[]} items
|
||||
* @property {string|null} activeParameter Name of the currently selected parameter
|
||||
* @property {number|null} stickyHeaderHeight
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineParameterSelectWidget = function VeUiMWTransclusionOutlineParameterSelectWidget( config ) {
|
||||
// Parent constructor
|
||||
|
@ -36,6 +37,7 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget = function VeUiMWTransclusionOu
|
|||
} );
|
||||
|
||||
this.activeParameter = null;
|
||||
this.stickyHeaderHeight = null;
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
@ -127,8 +129,8 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.setActiveParameter =
|
|||
* @inheritDoc OO.ui.SelectWidget
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.highlightItem = function ( item ) {
|
||||
if ( item ) {
|
||||
item.scrollToView();
|
||||
if ( item && this.stickyHeaderHeight ) {
|
||||
item.ensureVisibilityBelowStickyHeader( this.stickyHeaderHeight );
|
||||
}
|
||||
ve.ui.MWTransclusionOutlineParameterSelectWidget.super.prototype.highlightItem.call( this, item );
|
||||
};
|
||||
|
|
|
@ -87,9 +87,10 @@ ve.ui.MWTransclusionOutlineParameterWidget.prototype.toggleHasValue = function (
|
|||
|
||||
/**
|
||||
* Custom method to scroll parameter into view respecting the sticky part that sits above
|
||||
*
|
||||
* @param {number} stickyHeaderHeight
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineParameterWidget.prototype.scrollToView = function () {
|
||||
ve.ui.MWTransclusionOutlineParameterWidget.prototype.ensureVisibilityBelowStickyHeader = function ( stickyHeaderHeight ) {
|
||||
// make sure parameter is visible and scrolled underneath the sticky
|
||||
// TODO find a dynamic way to get height of the sticky part
|
||||
this.scrollElementIntoView( { animate: false, padding: { top: 114 } } );
|
||||
this.scrollElementIntoView( { animate: false, padding: { top: stickyHeaderHeight } } );
|
||||
};
|
||||
|
|
|
@ -350,6 +350,10 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.toggleFilters = function ()
|
|||
} else if ( visible ) {
|
||||
this.initializeFilters();
|
||||
this.updateUnusedParameterToggleState();
|
||||
if ( this.parameterList ) {
|
||||
// TODO find a dynamic way to get height of the sticky part
|
||||
this.parameterList.stickyHeaderHeight = 114;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -464,7 +468,8 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.scrollTopIntoView = function
|
|||
if ( this.parameterList ) {
|
||||
var firstSelected = this.parameterList.findFirstSelectedItem();
|
||||
if ( firstSelected ) {
|
||||
firstSelected.scrollToView();
|
||||
// FIXME: This code should be in {@see ve.ui.MWTransclusionOutlineParameterSelectWidget}
|
||||
firstSelected.ensureVisibilityBelowStickyHeader( this.parameterList.stickyHeaderHeight );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue