Skip to content

Commit 0d990b2

Browse files
committed
Flex panel final
1 parent e9755de commit 0d990b2

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

05 - Flex Panel Gallery/index-START.html

Lines changed: 39 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,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

@@ -54,6 +60,24 @@
5460
margin:0;
5561
width: 100%;
5662
transition:transform 0.5s;
63+
border: 1px solid red;
64+
flex: 1 0 auto;
65+
display: flex;
66+
justify-content: center;
67+
align-items: center;
68+
}
69+
70+
.panel > *:first-child {
71+
transform: translateY(-100%);
72+
}
73+
.panel.open-active > *:first-child {
74+
transform: translateY(0);
75+
}
76+
.panel > *:last-child {
77+
transform: translateY(100%);
78+
}
79+
.panel.open-active > *:last-child {
80+
transform: translateY(0);
5781
}
5882

5983
.panel p {
@@ -67,6 +91,7 @@
6791
}
6892

6993
.panel.open {
94+
flex: 5;
7095
font-size:40px;
7196
}
7297

@@ -107,7 +132,21 @@
107132
</div>
108133

109134
<script>
135+
const panels = document.querySelectorAll('.panel');
136+
137+
function toggleOpen(){
138+
this.classList.toggle('open');
139+
}
140+
141+
function toggleActive(e){
142+
console.log(e.propertyName);
143+
if(e.propertyName.includes('flex')){
144+
this.classList.toggle('open-active');
145+
}
146+
}
110147

148+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
149+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
111150
</script>
112151

113152

0 commit comments

Comments
 (0)