mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
15 lines
329 B
JavaScript
15 lines
329 B
JavaScript
export const scrollToTop = () => {
|
|
const { window } = global;
|
|
|
|
const scrollStep = -window.scrollY / (500 / 15);
|
|
const scrollInterval = setInterval(() => {
|
|
if (window.scrollY !== 0) {
|
|
window.scrollBy(0, scrollStep);
|
|
} else {
|
|
clearInterval(scrollInterval);
|
|
}
|
|
}, 15);
|
|
};
|
|
|
|
export default scrollToTop;
|