This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fasih/DPROD-3471/Removed lazy loading attribute from fast payment sec…
…tion logos (#7018) * fix: removed lazy loading for fast payment section * fix: implement hook for payment section * fix: implement is in viewport condition on data as well * fix: revert hook implementation on data --------- Co-authored-by: fasihali-deriv <[email protected]>
- Loading branch information
1 parent
449666d
commit 9858754
Showing
3 changed files
with
58 additions
and
28 deletions.
There are no files selected for viewing
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,20 @@ | ||
import React, { MutableRefObject, useEffect, useMemo, useState, useRef } from 'react' | ||
|
||
function useIsInViewport(ref: MutableRefObject<HTMLDivElement>) { | ||
const [isIntersecting, setIsIntersecting] = useState(false) | ||
const observer = useRef<IntersectionObserver>() | ||
|
||
useEffect(() => { | ||
observer.current = new IntersectionObserver(([entry]) => | ||
setIsIntersecting(entry.isIntersecting), | ||
) | ||
|
||
observer.current.observe(ref.current) | ||
|
||
return () => observer.current.disconnect() | ||
}, [ref.current, observer.current]) | ||
|
||
return isIntersecting | ||
} | ||
|
||
export default useIsInViewport |
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