Skip to content

Commit 7bcf4d0

Browse files
author
Patrick Santos
committed
complete wesbos#5 challenge
1 parent 61ebf2a commit 7bcf4d0

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
.panels {
2525
min-height:100vh;
2626
overflow: hidden;
27+
display: flex;
2728
}
2829

2930
.panel {
31+
display: flex;
3032
background:#6B0F9C;
3133
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
3234
color:white;
@@ -41,6 +43,10 @@
4143
font-size: 20px;
4244
background-size:cover;
4345
background-position:center;
46+
flex: 1;
47+
flex-direction: column;
48+
justify-content: center;
49+
align-items: center;
4450
}
4551

4652

@@ -53,7 +59,27 @@
5359
.panel > * {
5460
margin:0;
5561
width: 100%;
56-
transition:transform 0.5s;
62+
transition: transform 0.5s;
63+
flex: 1 0 auto;
64+
display: flex;
65+
justify-content: center;
66+
align-items: center;
67+
}
68+
69+
.panel > *:first-child {
70+
transform: translateY(-100%);
71+
}
72+
73+
.panel.open-active > *:first-child {
74+
transform: translateY(0);
75+
}
76+
77+
.panel > *:last-child {
78+
transform: translateY(100%);
79+
}
80+
81+
.panel.open-active > *:last-child {
82+
transform: translateY(0);
5783
}
5884

5985
.panel p {
@@ -67,6 +93,7 @@
6793
}
6894

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

@@ -102,7 +129,20 @@
102129
</div>
103130

104131
<script>
132+
const panels = document.querySelectorAll('.panel')
133+
134+
function toggleOpen () {
135+
this.classList.toggle('open');
136+
}
137+
138+
function toggleActive (e) {
139+
if (e.propertyName.includes('flex')) {
140+
this.classList.toggle('open-active')
141+
}
142+
}
105143

144+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
145+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
106146
</script>
107147

108148

0 commit comments

Comments
 (0)