Skip to content

Commit 5150fd7

Browse files
committed
finished JS Day wesbos#16
1 parent fb983d3 commit 5150fd7

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

12 - Key Sequence Detection/index-START.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,37 @@
66
<script type="text/javascript" src="http://www.cornify.com/js/cornify.js"></script>
77
</head>
88
<body>
9+
<style>
10+
11+
/* The animation code */
12+
@keyframes oaks {
13+
0% {transform: rotate(0deg) scale(1)}
14+
50% {transform: rotate(360deg) scale(3)}
15+
100% {transform: rotate(0deg) scale(1)}
16+
}
17+
18+
.oaksblokes {
19+
animation-name: oaks;
20+
animation-duration: 3s;
21+
animation-iteration-count: infinite;
22+
position : absolute;
23+
left: 30%;
24+
top: 20%;
25+
z-index : 9999;
26+
}
27+
28+
h1.oaksblokes-header {
29+
font-size: 100px;
30+
position: relative;
31+
color: #fff;
32+
text-align: center;
33+
z-index: 999999;
34+
}
35+
36+
</style>
937
<script>
38+
39+
function handleKeyUp(a){if(ENTRY.push(a.key),ENTRY.splice(-SECRET_PASSWORD.length-1,ENTRY.length-SECRET_PASSWORD.length),[SECRET_PASSWORD.split("")]==ENTRY&&(alert(),cornify_add()),ENTRY.join("")==SECRET_PASSWORD){const b=document.createElement("img"),c=document.createElement("h1");b.src="https://pbs.twimg.com/profile_images/823270999848288256/vGCDUDx9.jpg",c.innerHTML="JOIN THE OAKS!",b.classList.add("oaksblokes"),c.classList.add("oaksblokes-header");var d=document.querySelector("body");d.appendChild(b),d.appendChild(c)}}const SECRET_PASSWORD="oaksblokes",ENTRY=[];window.addEventListener("keyup",handleKeyUp);
1040
</script>
1141
</body>
1242
</html>

13 - Slide in on Scroll/index-START.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ <h1>Slide in on Scroll</h1>
5858
};
5959
}
6060

61+
62+
const images = document.querySelectorAll('img.slide-in');
63+
function checkSlide(){
64+
images.forEach(image => {
65+
const slideInAt = (window.scrollY + window.innerHeight) - image.height / 2
66+
const imageBottom = image.offsetTop + image.height
67+
const imageMiddleHeight = image.offsetTop + (image.height / 2)
68+
const isHalfShown = slideInAt > image.offsetTop
69+
const isNotScrolledPast = window.scrollY < imageBottom
70+
if (isHalfShown && isNotScrolledPast) {
71+
image.classList.add('active');
72+
} else {
73+
image.classList.remove('active');
74+
}
75+
})
76+
77+
}
78+
window.addEventListener('scroll', debounce(checkSlide))
79+
6180
</script>
6281

6382
<style>

16 - Mouse Move Shadow/index-start.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,42 @@ <h1 contenteditable>🔥WOAH!</h1>
2626
justify-content: center;
2727
align-items: center;
2828
color:black;
29+
border: 1px solid green;
2930
}
3031

3132
h1 {
3233
text-shadow: 10px 10px 0 rgba(0,0,0,1);
3334
font-size: 100px;
35+
background: lightblue;
3436
}
3537
</style>
3638

3739
<script>
40+
const walk = 100;
41+
const text = document.querySelector('h1');
42+
const hero = document.querySelector('.hero');
43+
44+
45+
function handleHeroHover(e){
46+
const width = hero.offsetWidth;
47+
const height = hero.offsetHeight;
48+
let x = e.offsetX
49+
let y = e.offsetY
50+
51+
if(this !== e.target){
52+
x = x + e.target.offsetLeft;
53+
y = y + e.target.offsetTop;
54+
}
55+
const xWalk = Math.round((x / width * walk) - (walk / 2));
56+
const yWalk = Math.round((y / width * walk) - (walk / 2));
57+
text.style.textShadow = `${xWalk}px ${yWalk}px 0 rgba(0,0,0,1)`
58+
}
59+
60+
61+
62+
hero.addEventListener('mousemove', handleHeroHover)
63+
64+
3865
</script>
3966
</body>
4067
</html>

0 commit comments

Comments
 (0)