File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 2424 .panels {
2525 min-height : 100vh ;
2626 overflow : hidden;
27+ display : flex;
2728 }
2829
2930 .panel {
4142 font-size : 20px ;
4243 background-size : cover;
4344 background-position : center;
45+ flex : 1 ;
46+ justify-content : center;
47+ align-items : center;
48+ display : flex;
49+ flex-direction : column;
4450 }
4551
4652
5460 margin : 0 ;
5561 width : 100% ;
5662 transition : transform 0.5s ;
63+ flex : 1 0 auto;
64+ display : flex;
65+ justify-content : center;
66+ align-items : center;
67+ }
68+
69+ .panel > * : first-child {
70+ transform : translateY (-100% );
71+ }
72+ .panel .open-active > * : first-child {
73+ transform : translateY (0 );
74+ }
75+ .panel > * : last-child {
76+ transform : translateY (100% );
77+ }
78+ .panel .open-active > * : last-child {
79+ transform : translateY (0 );
5780 }
5881
5982 .panel p {
6891
6992 .panel .open {
7093 font-size : 40px ;
94+ flex : 5 ;
7195 }
7296
7397 .cta {
107131 </ div >
108132
109133 < script >
134+ const panels = document . querySelectorAll ( '.panel' ) ;
135+
136+ function toggleOpen ( ) {
137+ this . classList . toggle ( 'open' ) ;
138+ }
139+
140+ function toggleActive ( e ) {
141+ if ( e . propertyName . includes ( 'flex' ) ) {
142+ this . classList . toggle ( 'open-active' ) ;
143+ }
144+ }
110145
146+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
147+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
111148 </ script >
112149
113150
You can’t perform that action at this time.
0 commit comments