Skip to content

Commit 3058fd4

Browse files
committed
Finished video 5
1 parent 37560e4 commit 3058fd4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

05 - Flex Panel Gallery/index-START.html

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

2930
.panel {
@@ -41,6 +42,11 @@
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

@@ -54,6 +60,23 @@
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+
.panel > *:last-child {
76+
transform: translateY(100%);
77+
}
78+
.panel.open-active > *:last-child {
79+
transform: translateY(0);
5780
}
5881

5982
.panel p {
@@ -68,6 +91,7 @@
6891

6992
.panel.open {
7093
font-size:40px;
94+
flex: 5;
7195
}
7296

7397
.cta {
@@ -107,7 +131,20 @@
107131
</div>
108132

109133
<script>
134+
const panels = document.querySelectorAll('.panel');
135+
136+
function toggleOpen() {
137+
this.classList.toggle('open');
138+
}
139+
140+
function toggleActive(e) {
141+
if (e.propertyName.includes('flex')) {
142+
this.classList.toggle('open-active');
143+
}
144+
}
110145

146+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
147+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
111148
</script>
112149

113150

0 commit comments

Comments
 (0)