From 62bd1b48ff7e1926d196f81965576f731f156cf7 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 17 Aug 2016 12:16:59 +0200 Subject: [PATCH] Updating page header min-height on resize --- .../WoltLabSuite/Core/Ui/Page/Header/Fixed.js | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Fixed.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Fixed.js index 27c77a87c6..0f6ee75cab 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Fixed.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Header/Fixed.js @@ -27,12 +27,42 @@ define(['Core', 'EventHandler', 'Ui/Alignment', 'Ui/CloseOverlay', 'Ui/Screen', this._initSearchBar(); UiScreen.on('screen-md-down', { - match: function() { _isMobile = true; }, - unmatch: function() { _isMobile = false; }, - setup: function() { _isMobile = true; } + match: this._toggleMobile.bind(this, true), + unmatch: this._toggleMobile.bind(this, false), + setup: this._toggleMobile.bind(this, true) }); }, + /** + * Toggles mobile flag. + * + * @param {boolean} isMobile true if this viewport equals at least a tablet + * @protected + */ + _toggleMobile: function (isMobile) { + _isMobile = isMobile; + + this._rebuildPageHeader(false); + }, + + /** + * Rebuilds the page header min-height property on viewport change. + * + * @protected + */ + _rebuildPageHeader: function () { + var clientHeight = _pageHeader.clientHeight; + + if (!clientHeight) { + _pageHeader.style.removeProperty('min-height'); + clientHeight = _pageHeader.clientHeight; + } + + if (clientHeight) { + _pageHeader.style.setProperty('min-height', clientHeight + 'px'); + } + }, + /** * Enforces a min-height for the original header's location to prevent collapsing * when setting the header to `position: fixed`. @@ -40,9 +70,7 @@ define(['Core', 'EventHandler', 'Ui/Alignment', 'Ui/CloseOverlay', 'Ui/Screen', * @protected */ _initStickyPageHeader: function() { - if (_pageHeader.clientHeight) { - _pageHeader.style.setProperty('min-height', _pageHeader.clientHeight + 'px'); - } + this._rebuildPageHeader(true); _triggerHeight = _pageHeader.clientHeight - elBySel('.mainMenu', _pageHeader).clientHeight; -- 2.20.1