Skip to content

Commit b2a0bae

Browse files
committed
Completed wesbos#5
1 parent 1e7b874 commit b2a0bae

File tree

1 file changed

+54
-8
lines changed

1 file changed

+54
-8
lines changed

05 - Flex Panel Gallery/index-START.html

+54-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
.panels {
2525
min-height:100vh;
2626
overflow: hidden;
27+
display: flex;
28+
flex-direction: row;
2729
}
2830

2931
.panel {
@@ -41,19 +43,43 @@
4143
font-size: 20px;
4244
background-size:cover;
4345
background-position:center;
46+
flex: 1;
47+
justify-content: center;
48+
align-items: center;
49+
display: flex;
50+
flex-direction: column;
4451
}
4552

46-
47-
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
48-
.panel2 { background-image:url(https://source.unsplash.com/rFKUFzjPYiQ/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); }
53+
/* hat tip: https://source.unsplash.com */
54+
.panel1 { background-image:url('https://source.unsplash.com/1500x1500/?hawaii'); }
55+
.panel2 { background-image:url('https://source.unsplash.com/1500x1500/?bali'); }
56+
.panel3 { background-image:url('https://source.unsplash.com/1500x1500/?tahiti'); }
57+
.panel4 { background-image:url('https://source.unsplash.com/1500x1500/?fiji'); }
58+
.panel5 { background-image:url('https://source.unsplash.com/1500x1500/?bermuda'); }
5259

5360
.panel > * {
54-
margin:0;
61+
margin: 0;
5562
width: 100%;
56-
transition:transform 0.5s;
63+
transition: transform 0.5s;
64+
/* border: 1px solid red; */
65+
flex: 1 0 auto;
66+
display: flex;
67+
justify-content: center;
68+
align-items: center;
69+
}
70+
71+
.panel > *:first-child {
72+
transform: translateY(-100%);
73+
}
74+
.panel.open-active > *:first-child {
75+
transform: translateY(0);
76+
}
77+
78+
.panel > *:last-child {
79+
transform: translateY(100%);
80+
}
81+
.panel.open-active > *:last-child {
82+
transform: translateY(0);
5783
}
5884

5985
.panel p {
@@ -68,6 +94,7 @@
6894

6995
.panel.open {
7096
font-size:40px;
97+
flex: 5;
7198
}
7299

73100
</style>
@@ -102,6 +129,25 @@
102129
</div>
103130

104131
<script>
132+
const panels = document.querySelectorAll('.panel');
133+
134+
function toggleOpen() {
135+
this.classList.toggle('open');
136+
}
137+
function toggleActive(e) {
138+
// console.log(e.propertyName);
139+
140+
const propName = e.propertyName;
141+
142+
if (propName.includes('flex')) {
143+
this.classList.toggle('open-active');
144+
}
145+
146+
// this.classList.toggle('.open-active');
147+
}
148+
149+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
150+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
105151

106152
</script>
107153

0 commit comments

Comments
 (0)