-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy-scripts.js
More file actions
83 lines (68 loc) · 1.94 KB
/
my-scripts.js
File metadata and controls
83 lines (68 loc) · 1.94 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//1. #progressBar
const progressBar = document.querySelector("#progressBar");
const body = document.querySelector("body");
const animateBar = () => {
let scrollDistance = -body.getBoundingClientRect().top;
let progressWidth =
(scrollDistance /
(body.getBoundingClientRect().height -
document.documentElement.clientHeight)) *
100;
let value = Math.floor(progressWidth);
progressBar.style.width = value + "%";
if (value < 0) {
progressBar.style.width = "0%";
}
};
window.addEventListener("scroll", animateBar);
//2. #scrollTop
var scrollTopBTN = document.getElementById("scrollTop");
var customNavItem = document.getElementById("customNav");
window.onscroll = function () {
scrollTopFunction();
NavScrollFunction();
};
scrollTopBTN.onclick = function () {
topFunction();
};
function scrollTopFunction() {
if (
document.body.scrollTop > 500 ||
document.documentElement.scrollTop > 500
) {
scrollTopBTN.classList.add("moveUp");
scrollTopBTN.innerHTML = "<i class='fa fa-angle-up'></i>";
scrollTopBTN.style.display = "block";
} else {
scrollTopBTN.style.transition = "0.2s";
scrollTopBTN.style.display = "none";
}
}
function NavScrollFunction() {
if (
document.body.scrollTop > 100 ||
document.documentElement.scrollTop > 100
) {
customNavItem.style.boxShadow = "var(--shadowsmall)";
customNavItem.style.transition = "0.2s";
} else {
customNavItem.style.boxShadow = "none";
customNavItem.style.transition = "0.2s";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
//3. #PassWord
var x = document.getElementById("PassWord");
var y = document.getElementById("PassWordIcon");
y.addEventListener("click", ShowPassWord);
function ShowPassWord() {
x.type = "text";
y.style.filter = "brightness(1.5)";
setTimeout(function () {
x.type = "password";
y.style.filter = "brightness(1)";
}, 1000);
}