From 6cfc46021fc67bfd58efc17c6a6ac2ff2b956fa4 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sun, 1 May 2022 19:54:24 +0200 Subject: [PATCH] Added parameter to configure the scroll behavior --- ts/WoltLabSuite/Core/Ui/Scroll.ts | 4 ++-- wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/Scroll.ts b/ts/WoltLabSuite/Core/Ui/Scroll.ts index afee101c23..288a6bcd3b 100644 --- a/ts/WoltLabSuite/Core/Ui/Scroll.ts +++ b/ts/WoltLabSuite/Core/Ui/Scroll.ts @@ -40,7 +40,7 @@ function onScroll(): void { * @param {Element} element target element * @param {function=} callback callback invoked once scrolling has ended */ -export function element(element: HTMLElement, callback?: Callback): void { +export function element(element: HTMLElement, callback?: Callback, behavior: ScrollBehavior = "smooth"): void { if (!(element instanceof HTMLElement)) { throw new TypeError("Expected a valid DOM element."); } else if (callback !== undefined && typeof callback !== "function") { @@ -83,7 +83,7 @@ export function element(element: HTMLElement, callback?: Callback): void { window.scrollTo({ left: 0, top: y, - behavior: "smooth", + behavior, }); window.setTimeout(() => { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js index bd701947bc..8ef9c90ea1 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Scroll.js @@ -28,7 +28,7 @@ define(["require", "exports", "tslib", "../Dom/Util"], function (require, export * @param {Element} element target element * @param {function=} callback callback invoked once scrolling has ended */ - function element(element, callback) { + function element(element, callback, behavior = "smooth") { if (!(element instanceof HTMLElement)) { throw new TypeError("Expected a valid DOM element."); } @@ -72,7 +72,7 @@ define(["require", "exports", "tslib", "../Dom/Util"], function (require, export window.scrollTo({ left: 0, top: y, - behavior: "smooth", + behavior, }); window.setTimeout(() => { // no scrolling took place -- 2.20.1