-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f83b10
commit dc4c1ec
Showing
44 changed files
with
507 additions
and
871 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
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,45 @@ | ||
"use client" | ||
|
||
import { createContext, useContext } from "react" | ||
import { motion, useReducedMotion } from "framer-motion" | ||
|
||
const FadeInStaggerContext = createContext(false) | ||
|
||
const viewport = { once: true, margin: "0px 0px -200px" } | ||
|
||
export function FadeIn(props: any) { | ||
let shouldReduceMotion = useReducedMotion() | ||
let isInStaggerGroup = useContext(FadeInStaggerContext) | ||
|
||
return ( | ||
<motion.div | ||
variants={{ | ||
hidden: { opacity: 0, y: shouldReduceMotion ? 0 : 24 }, | ||
visible: { opacity: 1, y: 0 }, | ||
}} | ||
transition={{ duration: 0.5 }} | ||
{...(isInStaggerGroup | ||
? {} | ||
: { | ||
initial: "hidden", | ||
whileInView: "visible", | ||
viewport, | ||
})} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
export function FadeInStagger({ faster = false, ...props }) { | ||
return ( | ||
<FadeInStaggerContext.Provider value={true}> | ||
<motion.div | ||
initial="hidden" | ||
whileInView="visible" | ||
viewport={viewport} | ||
transition={{ staggerChildren: faster ? 0.12 : 0.2 }} | ||
{...props} | ||
/> | ||
</FadeInStaggerContext.Provider> | ||
) | ||
} |
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.