Skip to content

Commit b60f74a

Browse files
committed
adding script wesbos#5
1 parent 1bd32a5 commit b60f74a

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

05 - Flex Panel Gallery/index-START.html

+29-3
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

@@ -50,12 +56,23 @@
5056
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
5157
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
5258

59+
60+
/* Flex Items*/
5361
.panel > * {
5462
margin:0;
5563
width: 100%;
5664
transition:transform 0.5s;
65+
flex: 1 0 auto;
66+
display: flex;
67+
justify-content: center;
68+
align-items: center;
5769
}
5870

71+
.panel > *:first-child {transform: translateY(-100%);}
72+
.panel.open-active > *:first-child {transform: translateY(0%);}
73+
.panel > *:last-child {transform: translateY(100%);}
74+
.panel.open-active > *:last-child {transform: translateY(0%);}
75+
5976
.panel p {
6077
text-transform: uppercase;
6178
font-family: 'Amatic SC', cursive;
@@ -67,6 +84,7 @@
6784
}
6885

6986
.panel.open {
87+
flex: 5;
7088
font-size:40px;
7189
}
7290

@@ -102,10 +120,18 @@
102120
</div>
103121

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

108-
109-
110136
</body>
111137
</html>

0 commit comments

Comments
 (0)