|
26 | 26 | .panels { |
27 | 27 | min-height: 100vh; |
28 | 28 | overflow: hidden; |
29 | | - } |
| 29 | + display: flex; |
| 30 | + } |
30 | 31 |
|
31 | 32 | .panel { |
32 | 33 | background: #6B0F9C; |
|
37 | 38 | /* Safari transitionend event.propertyName === flex */ |
38 | 39 | /* Chrome + FF transitionend event.propertyName === flex-grow */ |
39 | 40 | transition: |
40 | | - font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11), |
41 | | - flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11), |
| 41 | + font-size 1s cubic-bezier(0.61,-0.19, 0.7,-0.11), |
| 42 | + flex 1s cubic-bezier(0.61,-0.19, 0.7,-0.11), |
42 | 43 | background 0.2s; |
43 | 44 | font-size: 20px; |
44 | 45 | background-size: cover; |
45 | 46 | background-position: center; |
| 47 | + flex: 1; |
| 48 | + justify-content: center; |
| 49 | + align-items: center; |
| 50 | + display: flex; |
| 51 | + flex-direction: column; |
46 | 52 | } |
47 | 53 |
|
48 | 54 | .panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); } |
|
56 | 62 | margin: 0; |
57 | 63 | width: 100%; |
58 | 64 | transition: transform 0.5s; |
| 65 | + border: 1px solid red; |
| 66 | + flex: 1 0 auto; |
| 67 | + display: flex; |
| 68 | + justify-content: center; |
| 69 | + align-items: center; |
59 | 70 | } |
60 | 71 |
|
| 72 | + .panel > *:first-child { transform: translateY(-75%);} |
| 73 | + .panel.open-active > *:first-child { transform: translateY(0);} |
| 74 | + .panel > *:last-child {transform: translateY(90%);} |
| 75 | + .panel.open-active > *:last-child { transform: translateY(0);} |
| 76 | + |
| 77 | + |
61 | 78 | .panel p { |
62 | 79 | text-transform: uppercase; |
63 | 80 | font-family: 'Amatic SC', cursive; |
|
71 | 88 |
|
72 | 89 | .panel.open { |
73 | 90 | font-size: 40px; |
| 91 | + flex: 5; |
74 | 92 | } |
75 | 93 |
|
76 | 94 | </style> |
|
105 | 123 | </div> |
106 | 124 |
|
107 | 125 | <script> |
| 126 | + const panels = document.querySelectorAll('.panel'); |
| 127 | + |
| 128 | + function toggleOpen(){ |
| 129 | + console.log('Hello'); |
| 130 | + this.classList.toggle('open'); |
| 131 | + } |
| 132 | + |
| 133 | + function toggleActive(e) { |
| 134 | + console.log(e.propertyName); |
| 135 | + if(e.propertyName.includes('flex')) { |
| 136 | + this.classList.toggle('open-active'); |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + panels.forEach(panel => panel.addEventListener('click', toggleOpen)); |
| 141 | + panels.forEach(panel => panel.addEventListener('transitionend', toggleActive)); |
108 | 142 |
|
109 | 143 | </script> |
110 | 144 |
|
|
0 commit comments