Skip to content

Commit d7d708f

Browse files
author
Greg Pfaff
committed
JS30 wesbos#5
1 parent 56ccfb5 commit d7d708f

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 47 additions & 5 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,21 +42,44 @@
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

47-
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
48-
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
49-
.panel3 { background-image:url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); }
50-
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
51-
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
54+
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500);}
55+
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500);}
56+
.panel3 { background-image:url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d);}
57+
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500);}
58+
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500);}
5259

5360
.panel > * {
5461
margin:0;
5562
width: 100%;
5663
transition:transform 0.5s;
64+
flex: 1 0 auto;
65+
justify-content: center;
66+
align-items: center;
67+
display: flex;
68+
flex-direction: column;
5769
}
5870

71+
.panel > *:first-child {
72+
transform: translateY(-100%);
73+
}
74+
.panel.open-active > *:first-child {
75+
transform: translateY(0);
76+
}
77+
.panel > *:last-child {
78+
transform: translateY(100%);
79+
}
80+
.panel.open-active > *:last-child {
81+
transform: translateY(0);
82+
}
5983
.panel p {
6084
text-transform: uppercase;
6185
font-family: 'Amatic SC', cursive;
@@ -68,6 +92,7 @@
6892

6993
.panel.open {
7094
font-size:40px;
95+
flex: 4;
7196
}
7297

7398
.cta {
@@ -107,6 +132,23 @@
107132
</div>
108133

109134
<script>
135+
const panels = document.querySelectorAll('.panel');
136+
console.log(panels);
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+
}
148+
149+
panels.forEach((panel) => panel.addEventListener('click', toggleOpen));
150+
panels.forEach((panel) => panel.addEventListener('transitionend', toggleActive));
151+
110152

111153
</script>
112154

0 commit comments

Comments
 (0)