UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

33 lines (27 loc) 562 B
'use strict'; /*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ // src/isServer.ts function isServer() { return typeof window === "undefined"; } // src/onScrollStop/index.ts function onScrollStop(callback, timeout = 150) { if (isServer()) return; let isScrolling; window.addEventListener( "scroll", () => { clearTimeout(isScrolling); isScrolling = setTimeout(() => { callback(); }, timeout); }, false ); } exports.onScrollStop = onScrollStop;