Skip to content

Commit 8fca8a2

Browse files
committed
flex done
1 parent 99c62d7 commit 8fca8a2

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,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,25 @@
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+
76+
.panel > *:last-child {
77+
transform: translateY(100%);
78+
}
79+
80+
.panel.open-active > *:last-child {
81+
transform: translateY(0);
5782
}
5883

5984
.panel p {
@@ -68,6 +93,7 @@
6893

6994
.panel.open {
7095
font-size:40px;
96+
flex: 5;
7197
}
7298

7399
.cta {
@@ -107,7 +133,21 @@
107133
</div>
108134

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

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

113153

0 commit comments

Comments
 (0)