-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (51 loc) · 1.64 KB
/
script.js
File metadata and controls
71 lines (51 loc) · 1.64 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
$(document).ready(function() {
$(".menu-toggler").on("click", function() {
$(this).toggleClass("open");
$(".top-nav").toggleClass("open");
});
$(".top-nav .nav-link").on("click", function() {
$(".menu-toggler").removeClass("open");
$(".top-nav").removeClass("open");
});
});
// select skills selector
let ourSkills = document.querySelector(".skills");
mybutton = document.getElementById("myBtn");
scrollOnMenu = document.getElementById("top-nav");
function allSkills() {
let skillsOffsetTop = ourSkills.offsetTop;
let skillsOuterHeight = ourSkills.offsetHeight;
let windowHeight = this.innerHeight;
let windowScrollTop = this.pageYOffset;
if (windowScrollTop > skillsOffsetTop + skillsOuterHeight - windowHeight) {
let allSkills = document.querySelectorAll(
".skill-box .skill-progress span"
);
allSkills.forEach(skill => {
skill.style.width = skill.dataset.progress;
});
}
}
function topBtnFunction() {
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
function scrollMenuFunction() {
if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
$(".menu-toggler").removeClass("open");
$(".top-nav").removeClass("open");
}
}
window.onscroll = function() {
allSkills();
topBtnFunction();
scrollMenuFunction();
};