mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-14 08:54:04 +00:00
Dependencies overhaul - Update dependencies for all projects (except Mobile-only deps) - Remove unused dependencies from all projects (except Mobile-only deps) - Fix Storybook failing to import sd/ui style - Add Node 21 as not supported due to sass-loader not working on it yet - Add work-around for new rook version requiring webpack specific global property - Fix landing dev not working due to missing default env value on dev - Fix some incorrect uses of phosphor-icons non server side icons on server components on landing - Fix some incorrect uses of phosphor-icons server side icon on client components on landing - Fix landing fail to build on dev due to always required a Github Token to get the latest release - Fix new Next.js version not suporting Response.redirect due to immutable Headers - Add Gitlab as social link for teams page - Update Vítor's team photo - Add Vítor's twitter link - Fix some warning due to missing useEffect dependencies - Remove test-files dir - Fix QuickPreview unblurred buttons in Linux - Formatting
21 lines
518 B
TypeScript
21 lines
518 B
TypeScript
import { useEffect, useState } from 'react';
|
|
|
|
export const useScrolled = (ref: React.RefObject<HTMLDivElement>, y = 1) => {
|
|
const [isScrolled, setIsScrolled] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const onScroll = () => {
|
|
if (ref.current) {
|
|
if (ref.current.scrollTop >= y) setIsScrolled(true);
|
|
else setIsScrolled(false);
|
|
}
|
|
};
|
|
|
|
onScroll();
|
|
ref.current?.addEventListener('scroll', onScroll);
|
|
() => ref.current?.removeEventListener('scroll', onScroll);
|
|
}, [ref, y]);
|
|
|
|
return { isScrolled };
|
|
};
|