-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
54 lines (48 loc) · 1.31 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
52
53
54
//Scroll kembali keatas
let mybutton = document.getElementById("myBtn");
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (document.documentElement.scrollTop > 300) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.documentElement.scrollTop = 0;
}
//Ketik
var typed = new Typed(".auto-typed", {
strings: ["Good", "Excellent", "Perfect"],
typeSpeed: 100,
backSpeed: 100,
loop: true,
});
//Scroll muncul satu persatu
window.addEventListener("scroll", muncul);
function muncul() {
let elements = document.querySelectorAll(".naik");
for (let i = 0; i < elements.length; i++) {
let tinggiLayar = window.innerHeight;
let jarakAtasElemen = elements[i].getBoundingClientRect().top;
let ukuranScroll = 5;
if (jarakAtasElemen < tinggiLayar - ukuranScroll) {
elements[i].classList.add("tampil");
} else {
elements[i].classList.remove("tampil");
}
}
}
const spans = document.querySelectorAll("h1 span");
spans.forEach((span) =>
span.addEventListener("mouseover", function (e) {
span.classList.add("animated", "rubberBand");
})
);
spans.forEach((span) =>
span.addEventListener("mouseout", function (e) {
span.classList.remove("animated", "rubberBand");
})
);