-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
51 lines (41 loc) · 1.46 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var i = 0;
var txt = '/* University of St Andrews graduate in Computer Science from Northern Ireland */';
var speed = 50;
typeWriter = () => {
if (i < txt.length) {
document.getElementById("tw").innerHTML += txt.charAt(i);
i++;
setTimeout(typeWriter, speed);
}
}
window.onload = setTimeout(typeWriter, 800);
// First we get the viewport height and we multiple it by 1% to get a value for a vh unit
let vh = window.innerHeight * 0.01;
// Then we set the value in the --vh custom property to the root of the document
document.documentElement.style.setProperty('--vh', `${vh}px`);
// We listen to the resize event
window.addEventListener('resize', () => {
// We execute the same script as before
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
});
const btnScroll = document.getElementById("scroll");
btnScroll.addEventListener("click", function () {
document.getElementById('home').scrollIntoView();
})
//const logo = document.getElementById("logo");
const scrollContainer = document.getElementById("scroll-container");
scrollContainer.addEventListener("scroll", function() {
if (scrollContainer.scrollTop >= window.innerHeight/2) {
btnScroll.className = "showScroll"
//logo.className = "showLogo"
} else {
btnScroll.className = "hideScroll"
//logo.className = "hideLogo"
}
});//
ScrollOut({
scrollingElement: document.getElementById("scroll-container"),
threshold: 0.9,
once: true
});