File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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+ border : 1px solid red;
64+ flex : 1 0 auto;
65+ display : flex;
66+ justify-content : center;
67+ align-items : center;
68+ }
69+
70+ .panel > * : first-child {
71+ transform : translateY (-100% );
72+ }
73+ .panel .open-active > * : first-child {
74+ transform : translateY (0 );
75+ }
76+ .panel > * : last-child {
77+ transform : translateY (100% );
78+ }
79+ .panel .open-active > * : last-child {
80+ transform : translateY (0 );
5781 }
5882
5983 .panel p {
6791 }
6892
6993 .panel .open {
94+ flex : 5 ;
7095 font-size : 40px ;
7196 }
7297
107132 </ div >
108133
109134 < script >
135+ const panels = document . querySelectorAll ( '.panel' ) ;
136+
137+ function toggleOpen ( ) {
138+ this . classList . toggle ( 'open' ) ;
139+ }
140+
141+ function toggleActive ( e ) {
142+ console . log ( e . propertyName ) ;
143+ if ( e . propertyName . includes ( 'flex' ) ) {
144+ this . classList . toggle ( 'open-active' ) ;
145+ }
146+ }
110147
148+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) ) ;
149+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) ) ;
111150 </ script >
112151
113152
You can’t perform that action at this time.
0 commit comments