Visitar URL original
Day 3 · wesbos/JavaScript30@f1c359b · GitHub
Skip to content

Commit f1c359b

Browse files
author
Ryan
committed
Day 3
1 parent 6069e93 commit f1c359b

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎05 - Flex Panel Gallery/index-START.html‎

Lines changed: 25 additions & 1 deletion
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,10 @@
4142
font-size: 20px;
4243
background-size:cover;
4344
background-position:center;
45+
flex: 1;
46+
display: flex;
47+
justify-content: center;
48+
flex-direction: column;
4449
}
4550

4651

@@ -54,7 +59,15 @@
5459
margin:0;
5560
width: 100%;
5661
transition:transform 0.5s;
62+
flex: 1 0 auto;
63+
display: flex;
64+
justify-content: center;
65+
align-items: center;
5766
}
67+
.panel > *:first-child { transform: translateY(-100%);}
68+
.panel.open-active > *:first-child { transform: translateY(0);}
69+
.panel > *:last-child { transform: translateY(100%);}
70+
.panel.open-active > *:last-child { transform: translateY(0);}
5871

5972
.panel p {
6073
text-transform: uppercase;
@@ -67,6 +80,7 @@
6780
}
6881

6982
.panel.open {
83+
flex: 5;
7084
font-size:40px;
7185
}
7286

@@ -107,7 +121,17 @@
107121
</div>
108122

109123
<script>
110-
124+
const panels = document.querySelectorAll('.panel');
125+
function toggleOpen() {
126+
this.classList.toggle('open');
127+
}
128+
function toggleActive(e) {
129+
if (e.propertyName.includes('flex')) {
130+
this.classList.toggle('open-active');
131+
}
132+
}
133+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
134+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
111135
</script>
112136

113137

0 commit comments

Comments
 (0)