File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-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+
76+ .panel > * : last-child {
77+ transform : translateY (100% );
78+ }
79+
80+ .panel .open-active > * : last-child {
81+ transform : translateY (0 );
5782 }
5883
5984 .panel p {
6893
6994 .panel .open {
7095 font-size : 40px ;
96+ flex : 5 ;
7197 }
7298
7399 .cta {
107133 </ div >
108134
109135 < script >
136+ const panels = document . querySelectorAll ( '.panel' ) ;
137+
138+ function toggleOpen ( ) {
139+ this . classList . toggle ( 'open' ) ;
140+ }
141+
142+ function toggleActive ( e ) {
143+ console . log ( e . propertyName ) ;
144+ if ( e . propertyName . includes ( 'flex' ) ) {
145+ this . classList . toggle ( 'open-active' ) ;
146+ }
147+ }
110148
149+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
150+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
111151 </ script >
112152
113153
You can’t perform that action at this time.
0 commit comments