Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38513b9

Browse files
committed
added event listeners to transform elements on the page upon click
1 parent 45c48bc commit 38513b9

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

04 - Array Cardio Day 1/index.html

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,36 @@
6161
const nextGuy = b.passed - b.year;
6262
return lastGuy > nextGuy ? -1 : 1;
6363
});
64-
console.log(oldest);
64+
console.table(oldest);
6565
// 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name
6666
// https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris
67-
const category = document.querySelector('.mw-category');
68-
const links = category.querySelectorAll('a');
67+
// const category = document.querySelector('.mw-category');
68+
// const links = Array.from(category.querySelectorAll('a'));
69+
//
70+
// const de = links
71+
// .map(link => link.textContent)
72+
// .filter(streetName => streetName.includes('de'));
6973

7074
// 7. sort Exercise
7175
// Sort the people alphabetically by last name
72-
76+
const alpha = people.sort((lastOne, nextOne) => {
77+
const [aLast, aFirst] = lastOne.split(' ');
78+
const [bLast, bFirst] = lastOne.split(' ');
79+
return aLast > bLast ? 1 : -1;
80+
});
81+
console.log(alpha);
7382
// 8. Reduce Exercise
7483
// Sum up the instances of each of these
7584
const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ];
7685

86+
const transportation = data.reduce(function (obj, item) {
87+
if(!obj[item]) {
88+
obj[item] = 0;
89+
}
90+
obj[item]++;
91+
return obj;
92+
}, {});
93+
console.log(transportation);
7794
</script>
7895
</body>
7996
</html>

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
background-size:cover;
4444
background-position:center;
4545
flex: 1;
46+
align-items: center;
4647
justify-content: center;
4748
display: flex;
4849
flex-direction: column;
@@ -55,21 +56,20 @@
5556
.panel4 { background-image:url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); }
5657
.panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); }
5758

58-
/* Flex Items */
59+
/*flex children*/
5960
.panel > * {
6061
margin:0;
6162
width: 100%;
6263
transition:transform 0.5s;
6364
flex: 1 0 auto;
64-
display:flex;
65+
display: flex;
6566
justify-content: center;
6667
align-items: center;
6768
}
68-
69-
.panel > *:first-child { transform: translateY(-100%); }
70-
.panel.open-active > *:first-child { transform: translateY(0); }
71-
.panel > *:last-child { transform: translateY(100%); }
72-
.panel.open-active > *:last-child { transform: translateY(0); }
69+
.panel > *:first-child { transform: translateY(-100%);}
70+
.panel.open-active > *:first-child { transform: translateY(0);}
71+
.panel > *:last-child { transform: translateY(100%);}
72+
.panel.open-active > *:last-child { transform: translateY(0);}
7373

7474
.panel p {
7575
text-transform: uppercase;
@@ -82,8 +82,8 @@
8282
}
8383

8484
.panel.open {
85-
flex: 5;
8685
font-size:40px;
86+
flex: 5;
8787
}
8888

8989
.cta {
@@ -124,22 +124,21 @@
124124

125125
<script>
126126
const panels = document.querySelectorAll('.panel');
127-
128127
function toggleOpen() {
129-
console.log('Hello');
130128
this.classList.toggle('open');
131129
}
132-
133130
function toggleActive(e) {
134131
console.log(e.propertyName);
135-
if (e.propertyName.includes('flex')) {
132+
if(e.propertyName.includes('flex')) {
136133
this.classList.toggle('open-active');
137134
}
138135
}
139-
140136
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
141137
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));
142138
</script>
143139

140+
141+
144142
</body>
145143
</html>
144+
home

0 commit comments

Comments
 (0)