-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sett/landing-v2' into develop
- Loading branch information
Showing
35 changed files
with
851 additions
and
174 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useEffect, useMemo, useState } from "react"; | ||
|
||
const defaultOptions = { | ||
rootMargin: "0px 0px 0px 0px", | ||
threshold: 1, | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function useIsInViewport( | ||
ref: any, | ||
customOptions?: IntersectionObserverInit | ||
) { | ||
const [isIntersecting, setIsIntersecting] = useState(false); | ||
|
||
const options = useMemo(() => { | ||
return customOptions | ||
? { ...defaultOptions, ...customOptions } | ||
: defaultOptions; | ||
}, [customOptions]); | ||
|
||
const observer = useMemo( | ||
() => | ||
new IntersectionObserver(([entry]) => { | ||
if (!entry) return setIsIntersecting(false); | ||
return setIsIntersecting(entry.isIntersecting), options; | ||
}), | ||
[] | ||
); | ||
|
||
useEffect(() => { | ||
ref.current && observer.observe(ref.current); | ||
|
||
return () => { | ||
ref.current && observer.unobserve(ref.current); | ||
observer.disconnect(); | ||
}; | ||
}, [ref, observer]); | ||
|
||
return isIntersecting; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.