Skip to content

Commit a1a784c

Browse files
committed
flex panel gallery finished
1 parent 3492ede commit a1a784c

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 33 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,12 @@
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;
50+
4451
}
4552

4653

@@ -54,8 +61,17 @@
5461
margin:0;
5562
width: 100%;
5663
transition:transform 0.5s;
64+
flex: 1 0 auto;
65+
display: flex;
66+
justify-content: center;
67+
align-items: center;
5768
}
5869

70+
.panel > *:first-child { transform: translateY(-100%); }
71+
.panel.open-active > *:first-child { transform: translateY(0); }
72+
.panel > *:last-child { transform: translateY(100%); }
73+
.panel.open-active > *:last-child { transform: translateY(0); }
74+
5975
.panel p {
6076
text-transform: uppercase;
6177
font-family: 'Amatic SC', cursive;
@@ -67,6 +83,7 @@
6783
}
6884

6985
.panel.open {
86+
flex: 5;
7087
font-size:40px;
7188
}
7289

@@ -107,7 +124,22 @@
107124
</div>
108125

109126
<script>
110-
127+
const panels = document.querySelectorAll('.panel');
128+
129+
function toggleOpen() {
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+
141+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
142+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive))
111143
</script>
112144

113145

0 commit comments

Comments
 (0)