File tree Expand file tree Collapse file tree 3 files changed +111
-1
lines changed
packages/framer-motion/cypress/integration Expand file tree Collapse file tree 3 files changed +111
-1
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,8 @@ test-e2e: test-nextjs test-html test-react test-react-19
95
95
yarn test-playwright
96
96
97
97
test-single : build test-mkdir
98
- yarn start-server-and-test " yarn dev-server" http://localhost:9990 " cd packages/framer-motion && cypress run --headless --spec cypress/integration/animate-style.ts"
98
+ yarn start-server-and-test " yarn dev-server" http://localhost:9990 " cd packages/framer-motion && cypress run --headless --spec cypress/integration/layout-shared.ts"
99
+
99
100
100
101
lint : bootstrap
101
102
yarn lint
Original file line number Diff line number Diff line change
1
+ import { motion , MotionConfig } from "framer-motion"
2
+ import { useState } from "react"
3
+
4
+ const transition = {
5
+ // ease: () => 0.5,
6
+ duration : 10 ,
7
+ }
8
+
9
+ function BoxA ( { isOpen } : { isOpen : boolean } ) {
10
+ return (
11
+ < div style = { container } >
12
+ < motion . div
13
+ style = { { ...a , borderRadius : 24 } }
14
+ transition = { transition }
15
+ layoutId = "boxA"
16
+ />
17
+ { isOpen && (
18
+ < motion . div
19
+ className = "measure-box"
20
+ style = { { ...b , borderRadius : 0 } }
21
+ transition = { transition }
22
+ layoutId = "boxA"
23
+ />
24
+ ) }
25
+ </ div >
26
+ )
27
+ }
28
+
29
+ function BoxB ( { isOpen } : { isOpen : boolean } ) {
30
+ return (
31
+ < div style = { container } >
32
+ { ! isOpen ? (
33
+ < motion . div
34
+ key = "a"
35
+ style = { { ...a , borderRadius : 24 } }
36
+ transition = { transition }
37
+ layoutId = "boxB"
38
+ />
39
+ ) : (
40
+ < motion . div
41
+ key = "b"
42
+ className = "measure-box"
43
+ style = { { ...b , borderRadius : 0 } }
44
+ transition = { transition }
45
+ layoutId = "boxB"
46
+ />
47
+ ) }
48
+ </ div >
49
+ )
50
+ }
51
+
52
+ export const App = ( ) => {
53
+ const [ isOpen , setOpen ] = useState ( false )
54
+
55
+ return (
56
+ < MotionConfig transition = { { duration : 1 } } >
57
+ < button id = "next" onClick = { ( ) => setOpen ( ! isOpen ) } >
58
+ Next
59
+ </ button >
60
+ < BoxA isOpen = { isOpen } />
61
+ < BoxB isOpen = { isOpen } />
62
+ </ MotionConfig >
63
+ )
64
+ }
65
+
66
+ const box = {
67
+ background : "red" ,
68
+ gridArea : "1 / 1" ,
69
+ }
70
+
71
+ const container = {
72
+ display : "flex" ,
73
+ justifyContent : "center" ,
74
+ alignItems : "center" ,
75
+ gap : 20 ,
76
+ width : 300 ,
77
+ height : 300 ,
78
+ }
79
+
80
+ const a = {
81
+ ...box ,
82
+ width : 80 ,
83
+ height : 80 ,
84
+ }
85
+
86
+ const b = {
87
+ ...box ,
88
+ left : 200 ,
89
+ width : 140 ,
90
+ height : 140 ,
91
+ }
Original file line number Diff line number Diff line change @@ -1184,3 +1184,21 @@ describe("Shared layout: Measures rotated elements correctly when animation is i
1184
1184
} )
1185
1185
} )
1186
1186
} )
1187
+
1188
+ describe ( "Shared layout: Border radius" , ( ) => {
1189
+ it ( "Should animate border radius" , ( ) => {
1190
+ cy . visit ( "?test=layout-shared-border-radius" )
1191
+ . wait ( 50 )
1192
+ . get ( "#next" )
1193
+ . click ( )
1194
+ . wait ( 200 )
1195
+ . get ( ".measure-box" )
1196
+ . should ( ( [ $boxA , $boxB ] : any ) => {
1197
+ const boxAStyle = window . getComputedStyle ( $boxA )
1198
+ const boxBStyle = window . getComputedStyle ( $boxB )
1199
+ expect ( boxAStyle . borderRadius ) . not . to . equal ( "0%" )
1200
+ expect ( boxBStyle . borderRadius ) . not . to . equal ( "0%" )
1201
+ expect ( boxBStyle . borderRadius ) . to . equal ( boxAStyle . borderRadius )
1202
+ } )
1203
+ } )
1204
+ } )
You can’t perform that action at this time.
0 commit comments