-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
b434d51
commit 36e92ac
Showing
7 changed files
with
87 additions
and
67 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 |
---|---|---|
@@ -1,66 +1,11 @@ | ||
import { useEffect, useState } from "react" | ||
import { motion, motionValue, useAnimate } from "framer-motion" | ||
import { frame } from "framer-motion" | ||
|
||
/** | ||
* An example of the tween transition type | ||
*/ | ||
import { motion } from "framer-motion" | ||
|
||
const style = { | ||
width: 100, | ||
height: 100, | ||
background: "white", | ||
} | ||
|
||
const Child = ({ setState }: any) => { | ||
const [width] = useState(100) | ||
const [target, setTarget] = useState(0) | ||
const transition = { | ||
duration: 10, | ||
} | ||
|
||
const [scope, animate] = useAnimate() | ||
|
||
useEffect(() => { | ||
const controls = animate([ | ||
[ | ||
"div", | ||
{ x: 500, opacity: 0 }, | ||
{ type: "spring", duration: 1, bounce: 0 }, | ||
], | ||
]) | ||
|
||
// controls.then(() => { | ||
// controls.play() | ||
// }) | ||
|
||
return () => controls.stop() | ||
}, [target]) | ||
|
||
return ( | ||
<div ref={scope}> | ||
<motion.div | ||
id="box" | ||
style={{ | ||
x: target, | ||
...style, | ||
width: motionValue(width), | ||
y: width / 10, | ||
}} | ||
onClick={() => { | ||
setTarget(target + 100) | ||
// setWidth(width + 100) | ||
}} | ||
initial={{ borderRadius: 10 }} | ||
/> | ||
{/* <div style={style} onClick={() => setState(false)} /> */} | ||
</div> | ||
) | ||
return | ||
} | ||
|
||
export const App = () => { | ||
const [state, setState] = useState(true) | ||
|
||
return state && <Child setState={setState} /> | ||
return <motion.div animate={{ x: 100 }} style={style} /> | ||
} |
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,66 @@ | ||
import { useEffect, useState } from "react" | ||
import { motion, motionValue, useAnimate } from "framer-motion" | ||
import { frame } from "framer-motion" | ||
|
||
/** | ||
* An example of the tween transition type | ||
*/ | ||
|
||
const style = { | ||
width: 100, | ||
height: 100, | ||
background: "white", | ||
} | ||
|
||
const Child = ({ setState }: any) => { | ||
const [width] = useState(100) | ||
const [target, setTarget] = useState(0) | ||
const transition = { | ||
duration: 10, | ||
} | ||
|
||
const [scope, animate] = useAnimate() | ||
|
||
useEffect(() => { | ||
const controls = animate([ | ||
[ | ||
"div", | ||
{ x: 500, opacity: 0 }, | ||
{ type: "spring", duration: 1, bounce: 0 }, | ||
], | ||
]) | ||
|
||
controls.then(() => { | ||
controls.play() | ||
}) | ||
|
||
return () => controls.stop() | ||
}, [target]) | ||
|
||
return ( | ||
<div ref={scope}> | ||
<motion.div | ||
id="box" | ||
style={{ | ||
x: target, | ||
...style, | ||
width: motionValue(width), | ||
y: width / 10, | ||
}} | ||
onClick={() => { | ||
setTarget(target + 100) | ||
// setWidth(width + 100) | ||
}} | ||
initial={{ borderRadius: 10 }} | ||
/> | ||
{/* <div style={style} onClick={() => setState(false)} /> */} | ||
</div> | ||
) | ||
return | ||
} | ||
|
||
export const App = () => { | ||
const [state, setState] = useState(true) | ||
|
||
return state && <Child setState={setState} /> | ||
} |
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
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