-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
55 lines (37 loc) · 1.05 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
55
const links = document.querySelectorAll(".navbar a")
links.forEach(function (i) {
i.addEventListener('click', clickHandler);
});
function clickHandler(e) {
e.preventDefault();
const href = this.getAttribute("href");
const offsetTop = document.querySelector(href).offsetTop;
scrollTo({
top: offsetTop,
behavior: "smooth"
});
}
function heroGambarKecil() {
let nav = document.querySelector('.navbar');
let introPort = nav.getBoundingClientRect().top;
let screenPosition = window.innerHeight / 1.5;
if (introPort < screenPosition) {
nav.classList.toggle("sticky");
}
}
window.addEventListener('scroll', heroGambarKecil);
// on load
const content = document.querySelector(".content");
function codeAddress() {
content.classList.add('contentMuncul');
}
window.onload = codeAddress;
// Scroll-Top
const scroll = document.querySelector('.scroll-top');
scroll.addEventListener('click', function () {
window.scrollTo({
top: 0,
left: 0,
behavior: "smooth"
});
});