-
Notifications
You must be signed in to change notification settings - Fork 741
/
Animation-height-auto-padding.tsx
59 lines (55 loc) · 1.64 KB
/
Animation-height-auto-padding.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import * as React from "react"
import { useState } from "react"
import { motion, AnimatePresence } from "@framer"
export const App = () => {
const [isExpanded, setExpanded] = useState(false)
return (
<div className="example-container">
<AnimatePresence>
{isExpanded ? (
<motion.div
animate={{
height: "auto",
opacity: 1,
paddingTop: 30,
paddingBottom: 30,
}}
exit={{
height: 0,
opacity: 0,
paddingTop: 0,
paddingBottom: 0,
}}
initial={{
height: 0,
opacity: 0,
paddingTop: 0,
paddingBottom: 0,
}}
style={{ background: "white", width: 200 }}
>
Test
</motion.div>
) : null}
</AnimatePresence>
<button style={{}} onClick={() => setExpanded(!isExpanded)}>
Toggle
</button>
<style>{styles}</style>
</div>
)
}
const styles = `body {
background: white!important;
background-repeat: no-repeat;
padding: 0;
margin: 0;
display: flex;
justify-content: flex-start;
align-items: flex-start;
}
.example-container {
width: 320px;
padding: 20px;
}
}`