@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
27 lines (21 loc) • 506 B
JavaScript
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
// src/isServer.ts
function isServer() {
return typeof window === "undefined";
}
// src/scrollToTop/index.ts
function scrollToTop() {
if (isServer())
return;
const c = document.documentElement.scrollTop || document.body.scrollTop;
if (c > 0) {
window.requestAnimationFrame(scrollToTop);
window.scrollTo(0, c - c / 8);
}
}
exports.scrollToTop = scrollToTop;
;