useWindowScroll
ts
useWindowScroll(): Service<ScrollProps>The page scroll. It names the default case of useScroll(), and it is the same instance as useScroll() and useScroll(document.documentElement).
Usage
js
import { useWindowScroll } from '@studiometa/js-toolkit';
const unsubscribe = useWindowScroll().subscribe(({ y, progressY }) => {
document.documentElement.style.setProperty('--scroll-progress', String(progressY));
});Props, coalescing and extent observation are useScroll()'s.
Why it exists
useScroll() already defaults to the document element, so this export adds no behaviour. It adds a name: a call site that means "the page" says so, instead of relying on a reader knowing what the default argument is.
useWindowSize() is the same idea for useResize().