UNPKG

infinity-forge

Version:
28 lines 967 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useScroll = useScroll; var react_1 = require("react"); function useScroll(_a) { var maxScroll = _a.maxScroll, minScroll = _a.minScroll; var _b = (0, react_1.useState)(0), scroll = _b[0], setScroll = _b[1]; (0, react_1.useEffect)(function () { function handleScroll() { if (process.browser) { setScroll(window.scrollY); } } if (process.browser) { handleScroll(); window.addEventListener('scroll', handleScroll); return function () { window.removeEventListener('scroll', handleScroll); }; } }, []); return { scroll: scroll, isScrollMore: maxScroll !== undefined ? scroll > maxScroll : null, isScrollLess: minScroll !== undefined ? scroll < minScroll : null }; } //# sourceMappingURL=use-scroll.js.map