File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222 }
2323
2424 .panels {
25+ display : flex;
2526 min-height : 100vh ;
2627 overflow : hidden;
2728 }
2829
2930 .panel {
31+ display : flex;
32+ flex-direction : column;
33+ flex-grow : 1 ;
34+ justify-content : space-between;
35+ align-items : center;
3036 background : # 6B0F9C ;
3137 box-shadow : inset 0 0 0 5px rgba (255 , 255 , 255 , 0.1 );
3238 color : white;
4349 background-position : center;
4450 }
4551
52+ .panel > * : first-child { transform : translateY (-100% ); }
53+ .panel .open-active > * : first-child { transform : translateY (0 );}
54+ .panel > * : last-child { transform : translateY (100% ); }
55+ .panel .open-active > * : last-child { transform : translateY (0 );}
56+
4657
4758 .panel1 { background-image : url (https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
4859 .panel2 { background-image : url (https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
6879
6980 .panel .open {
7081 font-size : 40px ;
82+ flex-grow : 6 ;
7183 }
7284
7385 .cta {
107119 </ div >
108120
109121 < script >
122+ const panels = document . querySelectorAll ( '.panel' )
123+
124+ function toggleOpen ( ) {
125+ this . classList . toggle ( 'open' )
126+ }
127+
128+ function toggleActive ( event ) {
129+ console . log ( event . propertyName )
130+ if ( event . propertyName . includes ( 'flex' ) ) {
131+ this . classList . toggle ( 'open-active' )
132+ }
133+ }
110134
111- </ script >
135+ panels . forEach ( panel => panel . addEventListener ( 'click' , toggleOpen ) )
136+ panels . forEach ( panel => panel . addEventListener ( 'transitionend' , toggleActive ) )
137+ </ script >
112138
113139
114140
You can’t perform that action at this time.
0 commit comments