File tree Expand file tree Collapse file tree 3 files changed +61
-63
lines changed Expand file tree Collapse file tree 3 files changed +61
-63
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import Twitter from "@/components/icons/twitter.svg"
33
33
import Whitepaper from "@/components/icons/whitepaper.svg"
34
34
import { Image } from "@/components/Image"
35
35
import CardImage from "@/components/Image/CardImage"
36
+ import IntersectionObserverReveal from "@/components/IntersectionObserverReveal"
36
37
import MainArticle from "@/components/MainArticle"
37
38
import { ButtonLink } from "@/components/ui/buttons/Button"
38
39
import SvgButtonLink , {
@@ -624,14 +625,16 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
624
625
</ SectionContent >
625
626
626
627
{ /* dynamic / lazy loaded */ }
627
- < ValuesMarquee
628
- pairings = { valuesPairings }
629
- eventCategory = { eventCategory }
630
- categoryLabels = { {
631
- ethereum : tCommon ( "ethereum" ) ,
632
- legacy : t ( "page-index-values-legacy" ) ,
633
- } }
634
- />
628
+ < IntersectionObserverReveal rootMargin = "-50% 0px 0px 0px" >
629
+ < ValuesMarquee
630
+ pairings = { valuesPairings }
631
+ eventCategory = { eventCategory }
632
+ categoryLabels = { {
633
+ ethereum : tCommon ( "ethereum" ) ,
634
+ legacy : t ( "page-index-values-legacy" ) ,
635
+ } }
636
+ />
637
+ </ IntersectionObserverReveal >
635
638
</ Section >
636
639
637
640
{ /* Builders - Blockchain's biggest builder community */ }
Original file line number Diff line number Diff line change
1
+ "use client"
2
+
3
+ import { ReactNode , useState } from "react"
4
+ import { useIntersectionObserver } from "usehooks-ts"
5
+
6
+ import { cn } from "@/lib/utils/cn"
7
+
8
+ interface IntersectionObserverRevealProps {
9
+ children : ReactNode
10
+ threshold ?: number
11
+ className ?: string
12
+ rootMargin ?: string
13
+ }
14
+
15
+ const IntersectionObserverReveal = ( {
16
+ children,
17
+ threshold = 0 ,
18
+ className,
19
+ rootMargin,
20
+ } : IntersectionObserverRevealProps ) => {
21
+ const { ref, isIntersecting } = useIntersectionObserver ( {
22
+ threshold,
23
+ root : null ,
24
+ rootMargin,
25
+ } )
26
+
27
+ // once the element is visible, set a flag to prevent the element from being hidden again
28
+ const [ hasBeenVisible , setHasBeenVisible ] = useState ( false )
29
+
30
+ if ( isIntersecting && ! hasBeenVisible ) {
31
+ setHasBeenVisible ( true )
32
+ }
33
+
34
+ return (
35
+ < div ref = { ref } className = { cn ( "w-full" , className ) } >
36
+ { ( isIntersecting || hasBeenVisible ) && (
37
+ < div
38
+ className = { cn (
39
+ "transition-opacity duration-700" ,
40
+ isIntersecting || hasBeenVisible ? "opacity-100" : "opacity-0"
41
+ ) }
42
+ >
43
+ { children }
44
+ </ div >
45
+ ) }
46
+ </ div >
47
+ )
48
+ }
49
+
50
+ export default IntersectionObserverReveal
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments