-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
53 lines (39 loc) · 1.25 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
const hamburger = document.querySelector(".hamburger");
const navMenu = document.querySelector(".nav-menu");
hamburger.addEventListener("click", mobileMenu);
function mobileMenu() {
hamburger.classList.toggle("active");
navMenu.classList.toggle("active");
}
const navLink = document.querySelectorAll(".nav-link");
navLink.forEach(n => n.addEventListener("click", closeMenu));
function closeMenu() {
hamburger.classList.remove("active");
navMenu.classList.remove("active");
}
var images;
// Describe this function...
function forward() {
if(--window.LoopTrap <= 0) throw "Infinite loop.";
images.push(images.shift());
}
// Describe this function...
function back() {
if(--window.LoopTrap <= 0) throw "Infinite loop.";
images.unshift(images.pop());
}
images = ['pic1.jpg',
'pic2.jpg',
'pic3.jpg',
'pic5.jpg',
'kapci.jpg'];
document.getElementById('next').addEventListener('click', (event) => {
let element_img_blank = document.getElementById('img_blank');
forward();
element_img_blank.setAttribute("src", images[0]);
});
document.getElementById('previous').addEventListener('click', (event) => {
let element_img_blank2 = document.getElementById('img_blank');
back();
element_img_blank2.setAttribute("src", images.slice(-1)[0]);
});