Skip to content

Commit 9ef1de2

Browse files
followed along w/exercise
1 parent 0f7824c commit 9ef1de2

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

05 - Flex Panel Gallery/index-START.html

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
.panels {
2727
min-height: 100vh;
2828
overflow: hidden;
29-
}
29+
display: flex;
30+
}
3031

3132
.panel {
3233
background: #6B0F9C;
@@ -37,12 +38,17 @@
3738
/* Safari transitionend event.propertyName === flex */
3839
/* Chrome + FF transitionend event.propertyName === flex-grow */
3940
transition:
40-
font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41-
flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
41+
font-size 1s cubic-bezier(0.61,-0.19, 0.7,-0.11),
42+
flex 1s cubic-bezier(0.61,-0.19, 0.7,-0.11),
4243
background 0.2s;
4344
font-size: 20px;
4445
background-size: cover;
4546
background-position: center;
47+
flex: 1;
48+
justify-content: center;
49+
align-items: center;
50+
display: flex;
51+
flex-direction: column;
4652
}
4753

4854
.panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); }
@@ -56,8 +62,19 @@
5662
margin: 0;
5763
width: 100%;
5864
transition: transform 0.5s;
65+
border: 1px solid red;
66+
flex: 1 0 auto;
67+
display: flex;
68+
justify-content: center;
69+
align-items: center;
5970
}
6071

72+
.panel > *:first-child { transform: translateY(-75%);}
73+
.panel.open-active > *:first-child { transform: translateY(0);}
74+
.panel > *:last-child {transform: translateY(90%);}
75+
.panel.open-active > *:last-child { transform: translateY(0);}
76+
77+
6178
.panel p {
6279
text-transform: uppercase;
6380
font-family: 'Amatic SC', cursive;
@@ -71,6 +88,7 @@
7188

7289
.panel.open {
7390
font-size: 40px;
91+
flex: 5;
7492
}
7593

7694
</style>
@@ -105,6 +123,22 @@
105123
</div>
106124

107125
<script>
126+
const panels = document.querySelectorAll('.panel');
127+
128+
function toggleOpen(){
129+
console.log('Hello');
130+
this.classList.toggle('open');
131+
}
132+
133+
function toggleActive(e) {
134+
console.log(e.propertyName);
135+
if(e.propertyName.includes('flex')) {
136+
this.classList.toggle('open-active');
137+
}
138+
}
139+
140+
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
141+
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
108142

109143
</script>
110144

0 commit comments

Comments
 (0)