* @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") {
window.scrollTo({
left: 0,
top: y,
- behavior: "smooth",
+ behavior,
});
window.setTimeout(() => {
* @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.");
}
window.scrollTo({
left: 0,
top: y,
- behavior: "smooth",
+ behavior,
});
window.setTimeout(() => {
// no scrolling took place