This repository was archived by the owner on Feb 13, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change 22
22
}
23
23
24
24
.panels {
25
+ display : flex;
25
26
min-height : 100vh ;
26
27
overflow : hidden;
27
28
}
30
31
background : # 6B0F9C ;
31
32
box-shadow : inset 0 0 0 5px rgba (255 , 255 , 255 , 0.1 );
32
33
color : white;
34
+ flex : 1 ;
35
+ justify-content : center;
36
+ display : flex;
37
+ flex-direction : column;
38
+ align-items : center;
33
39
text-align : center;
34
40
align-items : center;
35
41
/* Safari transitionend event.propertyName === flex */
54
60
margin : 0 ;
55
61
width : 100% ;
56
62
transition : transform 0.5s ;
63
+ display : flex;
64
+ justify-content : center;
65
+ align-items : center;
66
+ flex : 1 0 auto;
67
+ }
68
+
69
+ .panel > * : first-child {
70
+ transform : translateY (-100% );
71
+ }
72
+
73
+ .panel .open-active > * : first-child {
74
+ transform : translateY (0 );
75
+ }
76
+
77
+ .panel > * : last-child {
78
+ transform : translateY (100% );
79
+ }
80
+
81
+ .panel .open-active > * : last-child {
82
+ transform : translateY (0 );
57
83
}
58
84
59
85
.panel p {
67
93
}
68
94
69
95
.panel .open {
96
+ flex : 5 ;
70
97
font-size : 40px ;
71
98
}
72
99
107
134
</ div >
108
135
109
136
< script >
137
+ const panels = document . querySelectorAll ( '.panel' ) ;
110
138
111
- </ script >
139
+ panels . forEach ( panel => panel . addEventListener ( 'click' , ( ) => {
140
+ panel . classList . toggle ( 'open' ) ;
141
+ } ) ) ;
112
142
143
+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , ( evt ) => {
144
+ if ( ! evt . propertyName . includes ( 'flex' ) ) return ;
113
145
146
+ panel . classList . toggle ( 'open-active' ) ;
147
+ } ) ) ;
148
+ </ script >
114
149
115
150
</ body >
116
151
</ html >
You can’t perform that action at this time.
0 commit comments