Ignore certain scroll events that are just side effects
authorAlexander Ebert <ebert@woltlab.com>
Fri, 7 Aug 2020 14:52:41 +0000 (16:52 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 7 Aug 2020 14:52:41 +0000 (16:52 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Action.js

index 429a28f2121584a6fa5eaf4c108724a912b19a36..db018aaa6cb2833ca0cd3a7a59b617cc768f5f30 100644 (file)
@@ -72,7 +72,18 @@ define(['Dictionary', 'Language'], function (Dictionary, Language) {
                 * @param {Event=} event
                 */
                _onScroll: function (event) {
+                       if (document.documentElement.classList.contains('disableScrolling')) {
+                               // Ignore any scroll events that take place while body scrolling is disabled,
+                               // because it messes up the scroll offsets.
+                               return;
+                       }
+                       
                        var offset = window.pageYOffset;
+                       if (offset === _lastPosition) {
+                               // Ignore any scroll event that is fired but without a position change. This can
+                               // happen after closing a dialog that prevented the body from being scrolled.
+                               return;
+                       }
                        
                        if (offset >= 300) {
                                if (_toTopButton.classList.contains('initiallyHidden')) {