Skip to content

Commit ad53f57

Browse files
author
Brian Carrigan
committed
Finish wesbos#5 at 30k feet.
1 parent 2eb7ee3 commit ad53f57

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
.panels {
2525
min-height:100vh;
2626
overflow: hidden;
27+
display: flex;
2728
}
2829

2930
.panel {
31+
flex: 1;
3032
background:#6B0F9C;
3133
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
3234
color:white;
@@ -41,6 +43,10 @@
4143
font-size: 20px;
4244
background-size:cover;
4345
background-position:center;
46+
justify-content: center;
47+
align-items: center;
48+
display: flex;
49+
flex-direction: column;
4450
}
4551

4652

@@ -54,6 +60,27 @@
5460
margin:0;
5561
width: 100%;
5662
transition:transform 0.5s;
63+
flex: 1;
64+
display: flex;
65+
align-items: center;
66+
flex-direction: center;
67+
justify-content: center;
68+
}
69+
70+
.panel > *:first-child {
71+
transform: translateY(-100%);
72+
}
73+
74+
.panel.open-active > *:first-child {
75+
transform: translateY(0%);
76+
}
77+
78+
.panel > *:last-child {
79+
transform: translateY(100%);
80+
}
81+
82+
.panel.open-active > *:last-child {
83+
transform: translateY(0%);
5784
}
5885

5986
.panel p {
@@ -68,6 +95,7 @@
6895

6996
.panel.open {
7097
font-size:40px;
98+
flex: 5;
7199
}
72100

73101
.cta {
@@ -107,7 +135,19 @@
107135
</div>
108136

109137
<script>
138+
const panels = document.querySelectorAll('.panel');
139+
140+
function toggleOpen() {
141+
this.classList.toggle('open');
142+
}
143+
144+
function transitionText(e) {
145+
if (!e.propertyName.includes('flex')) return;
146+
this.classList.toggle('open-active');
147+
}
110148

149+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
150+
panels.forEach(panel => panel.addEventListener('transitionend', transitionText));
111151
</script>
112152

113153

0 commit comments

Comments
 (0)