Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add layout="size" for size-only layout animations
- Loading branch information
Showing
7 changed files
with
162 additions
and
9 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from "react" | ||
import { useState } from "react" | ||
import { motion } from "@framer" | ||
|
||
const textA = ` | ||
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). | ||
` | ||
|
||
const textB = ` | ||
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. | ||
` | ||
|
||
export function App() { | ||
const [c, setC] = useState(1) | ||
|
||
return ( | ||
<div | ||
id="parent" | ||
onClick={() => setC((i) => -1 * i)} | ||
style={{ | ||
backgroundColor: "#fff", | ||
padding: 40, | ||
overflow: "hidden", | ||
maxWidth: 500, | ||
position: "absolute", | ||
top: c * 10 + 100, | ||
left: c * 10 + 100, | ||
}} | ||
> | ||
<motion.div | ||
layout="size" | ||
id="child" | ||
transition={transition} | ||
style={{ backgroundColor: "#ccc" }} | ||
> | ||
{c === 1 ? textA : textB} | ||
</motion.div> | ||
</div> | ||
) | ||
} | ||
|
||
const transition = { | ||
duration: 3, | ||
} |
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