Skip to content

Commit ef27fd6

Browse files
committed
finished JS Day wesbos#5
1 parent 9e679d0 commit ef27fd6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 28 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,8 +60,17 @@
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 > *:last-child { transform: translateY(100%); }
71+
.panel.open-active > *:first-child { transform: translateY(0); }
72+
.panel.open-active > *:last-child { transform: translateY(0); }
73+
5974
.panel p {
6075
text-transform: uppercase;
6176
font-family: 'Amatic SC', cursive;
@@ -68,6 +83,7 @@
6883

6984
.panel.open {
7085
font-size:40px;
86+
flex: 5;
7187
}
7288

7389
</style>
@@ -102,7 +118,19 @@
102118
</div>
103119

104120
<script>
121+
function panelHandleClick(){
122+
this.classList.toggle('open')
123+
}
124+
function panelHandleTransitionEnd(e){
125+
if(e.propertyName !== "flex-grow") return
126+
this.classList.toggle('open-active')
127+
128+
}
105129

130+
const panels = document.querySelectorAll('.panel').forEach((panel) => {
131+
panel.addEventListener('click', panelHandleClick);
132+
panel.addEventListener('transitionend', panelHandleTransitionEnd)
133+
})
106134
</script>
107135

108136

0 commit comments

Comments
 (0)