Skip to content

Commit 0baa8cd

Browse files
committed
This was fun!
1 parent a316637 commit 0baa8cd

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

05 - Flex Panel Gallery/index-START.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@
2222
}
2323

2424
.panels {
25+
display: flex;
2526
min-height:100vh;
2627
overflow: hidden;
2728
}
2829

2930
.panel {
31+
display: flex;
32+
flex-direction: column;
33+
flex-grow: 1;
34+
justify-content: space-between;
35+
align-items: center;
3036
background:#6B0F9C;
3137
box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1);
3238
color:white;
@@ -43,6 +49,11 @@
4349
background-position:center;
4450
}
4551

52+
.panel > *:first-child { transform: translateY(-100%); }
53+
.panel.open-active > *:first-child { transform: translateY(0);}
54+
.panel > *:last-child { transform: translateY(100%); }
55+
.panel.open-active > *:last-child { transform: translateY(0);}
56+
4657

4758
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
4859
.panel2 { background-image:url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); }
@@ -68,6 +79,7 @@
6879

6980
.panel.open {
7081
font-size:40px;
82+
flex-grow: 6;
7183
}
7284

7385
.cta {
@@ -107,8 +119,22 @@
107119
</div>
108120

109121
<script>
122+
const panels = document.querySelectorAll('.panel')
123+
124+
function toggleOpen() {
125+
this.classList.toggle('open')
126+
}
127+
128+
function toggleActive(event) {
129+
console.log(event.propertyName)
130+
if(event.propertyName.includes('flex')){
131+
this.classList.toggle('open-active')
132+
}
133+
}
110134

111-
</script>
135+
panels.forEach(panel => panel.addEventListener('click', toggleOpen))
136+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive))
137+
</script>
112138

113139

114140

0 commit comments

Comments
 (0)