Skip to content

Commit

Permalink
do nothing and return false when target is null
Browse files Browse the repository at this point in the history
  • Loading branch information
vipierozan99 committed Mar 3, 2025
1 parent b01eb82 commit 680496f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface UseScrollTriggerOptions {
disableHysteresis?: boolean;
target?: Node | Window;
target?: Node | Window | null;
threshold?: number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export default function useScrollTrigger(options = {}) {
const store = React.useRef();
const [trigger, setTrigger] = React.useState(() => getTrigger(store, other));
React.useEffect(() => {
if (target === null) {
setTrigger(false);
return undefined;
}
const handleScroll = () => {
setTrigger(getTrigger(store, { target, ...other }));
};
Expand Down

0 comments on commit 680496f

Please sign in to comment.