forked from mensahtribe/mensah-tribe-web-solutions-plan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
43 lines (37 loc) · 999 Bytes
/
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
// Navbar condition
const navbar = document.getElementById('navbar');
let scrolled = false;
window.onscroll = function () {
if (window.pageYOffset > 100) {
navbar.classList.remove('top');
if (!scrolled) {
navbar.style.transform = "translateY(-70px)";
}
setTimeout(function () {
navbar.style.transform = "translateY(0)";
scrolled = true;
}, 200);
} else {
navbar.classList.add('top');
scrolled = false;
}
}
// smooth Scrolling
$('#navbar a, .btn').on('click', function (e) {
if (this.hash !== '') {
e.preventDefault();
const hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top - 100,
},
800
);
}
});
// js example
// const para = document.getElementById('js-example');
// para.addEventListener('click', updateName);
// function updateName() {
// let name = prompt('Enter a new name');
// para.textContent = 'Player 1: ' + name;
// }