Files

14 lines
414 B
TypeScript
Raw Permalink Normal View History

/** Reactive `window.scrollY > threshold`, evaluated after mount (passive listener). */
export function useScrolledPast(threshold: number) {
const past = ref(false);
const on = () => (past.value = window.scrollY > threshold);
onMounted(() => {
on();
window.addEventListener("scroll", on, { passive: true });
});
onBeforeUnmount(() => window.removeEventListener("scroll", on));
return past;
}