-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
59 lines (46 loc) · 1.37 KB
/
script.js
File metadata and controls
59 lines (46 loc) · 1.37 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
const img = document.getElementById("modal-img");
const overlay = document.getElementById('overlay')
const modal = document.getElementById('modal')
let isNavOpen = false;
function openModal(m) {
img.src =`assets/certifications/cer-${m}.png`;
modal.classList.add('active')
overlay.classList.add('active')
console.log(m)
}
function closeModal() {
isNavOpen&&openCloseNav();
modal.classList.remove('active')
overlay.classList.remove('active')
}
// ------------------------ goto top ---------------------------------
let mybutton = document.getElementById("gotop");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if ( document.documentElement.scrollTop > 100) {
mybutton.style.zIndex = "10";
mybutton.style.opacity = "1";
} else {
mybutton.style.zIndex = "-2";
mybutton.style.opacity = "0";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
// ---------------------- open nav ---------------------------------
function openCloseNav(){
if(window.innerWidth<=768){
if(isNavOpen){
isNavOpen=false;
closeModal();
document.querySelector("#navBar").style.left="-200px";
}
else{
isNavOpen=true;
openModal();
document.querySelector("#navBar").style.left="0";
}
}
}