From 895bfcf1e2998ccf6eb943e8046f9368cf914a5a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 18 Jun 2017 11:58:53 +0200 Subject: [PATCH] Fixed static scroll offset calculation --- .../files/js/WoltLabSuite/Core/Ui/Scroll.js | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js index ace1b9f6a7..836ff82479 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js @@ -11,6 +11,7 @@ define(['Dom/Util'], function(DomUtil) { var _callback = null; var _callbackScroll = null; + var _offset = null; var _timeoutScroll = null; /** @@ -48,13 +49,28 @@ define(['Dom/Util'], function(DomUtil) { } var y = DomUtil.offset(element).top; - - if (y <= 50) { - y = 0; + if (_offset === null) { + _offset = 50; + var pageHeader = elById('pageHeaderPanel'); + if (pageHeader !== null) { + var position = window.getComputedStyle(pageHeader).position; + if (position === 'fixed' || position === 'static') { + _offset = pageHeader.offsetHeight; + } + else { + _offset = 0; + } + } } - else { - // add an offset of 50 pixel to account for a sticky header - y -= 50; + + if (_offset > 0) { + if (y <= _offset) { + y = 0; + } + else { + // add an offset to account for a sticky header + y -= _offset; + } } var offset = window.pageYOffset; -- 2.20.1