Skip to content

Commit b29967d

Browse files
committed
Finished day 5
1 parent b6c49ed commit b29967d

File tree

3 files changed

+34
-146
lines changed

3 files changed

+34
-146
lines changed

05 - Flex Panel Gallery/flex.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const panels = document.querySelectorAll('.panel')
2+
3+
function toggleOpen () {
4+
this.classList.toggle('open')
5+
}
6+
7+
function toggleActive (e) {
8+
console.log(e.propertyName);
9+
if (e.propertyName.includes('flex')) {
10+
this.classList.toggle('open-active');
11+
}
12+
}
13+
14+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
15+
panels.forEach(panel => panel.addEventListener('transitionend',
16+
toggleActive));

05 - Flex Panel Gallery/index-FINISHED.html

Lines changed: 0 additions & 145 deletions
This file was deleted.

05 - Flex Panel Gallery/index-START.html renamed to 05 - Flex Panel Gallery/index.html

Lines changed: 18 additions & 1 deletion
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,8 +60,18 @@
5460
margin:0;
5561
width: 100%;
5662
transition:transform 0.5s;
63+
flex: 1 0 auto;
64+
display: flex;
65+
justify-content: center;
66+
align-items: center;
5767
}
5868

69+
.panel > *:first-child { transform: translateY(-100%) ; }
70+
.panel.open-active > *:first-child { transform: translateY(0%) ; }
71+
72+
.panel > *:last-child { transform: translateY(100%) ; }
73+
.panel.open-active > *:last-child { transform: translateY(0%) ; }
74+
5975
.panel p {
6076
text-transform: uppercase;
6177
font-family: 'Amatic SC', cursive;
@@ -67,6 +83,7 @@
6783
}
6884

6985
.panel.open {
86+
flex: 5;
7087
font-size:40px;
7188
}
7289

@@ -106,7 +123,7 @@
106123
</div>
107124
</div>
108125

109-
<script>
126+
<script src="flex.js">
110127

111128
</script>
112129

0 commit comments

Comments
 (0)