Skip to content

Commit 7a1ed7f

Browse files
committed
completed wesbos#5
1 parent 258d831 commit 7a1ed7f

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 48 additions & 0 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,9 +42,16 @@
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

53+
54+
4755
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
4856
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
4957
.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); }
@@ -54,6 +62,27 @@
5462
margin:0;
5563
width: 100%;
5664
transition:transform 0.5s;
65+
66+
flex: 1 0 auto;
67+
display:flex;
68+
justify-content: center;
69+
align-items: center;
70+
}
71+
72+
.panel > *:first-child {
73+
transform: translateY(-100%);
74+
}
75+
76+
.panel.open-active > *:first-child {
77+
transform: translateY(0);
78+
}
79+
80+
.panel > *:last-child {
81+
transform: translateY(100%);
82+
}
83+
84+
.panel.open-active > *:last-child {
85+
transform: translateY(0);
5786
}
5887

5988
.panel p {
@@ -68,6 +97,7 @@
6897

6998
.panel.open {
7099
font-size:40px;
100+
flex:5;
71101
}
72102

73103
.cta {
@@ -107,7 +137,25 @@
107137
</div>
108138

109139
<script>
140+
const panels = document.querySelectorAll('.panel');
141+
142+
function toggleOpen(){
143+
this.classList.toggle('open');
144+
}
145+
146+
function toggleActive (e) {
147+
if (e.propertyName.includes('flex')) {
148+
this.classList.toggle('open-active');
149+
}
150+
}
151+
152+
panels.forEach(function(panel){
153+
panel.addEventListener('click',toggleOpen);
154+
});
110155

156+
panels.forEach(function(panel){
157+
panel.addEventListener('transitionend',toggleActive);
158+
});
111159
</script>
112160

113161

0 commit comments

Comments
 (0)