-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
45 lines (38 loc) · 1.15 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
var flkty = new Flickity('#photolist', {
"cellAlign": "center",
"wrapAround": true,
"pageDots": false,
"adaptiveHeight": true,
"lazyLoad": 2,
on: {
change: function (index) {
setUrl(index);
}
}
});
setPhoto();
// Event listeners
document.querySelector("div#hamburger a").addEventListener("click", toggleNav);
window.addEventListener("load", function () {
setTimeout(function () {
// This hides the address bar:
window.scrollTo(0, 1);
}, 0);
});
// Toggle responsive navigation
function toggleNav() {
const element = document.getElementById("mainnav");
const toggleBtn = document.querySelector("div#navtoggle");
element.style.left = element.left ? "-100%" : "0";
toggleBtn.classList.toggle("change");
}
function setPhoto() {
const photoId = document.getElementById("hidPhotoNumber").value;
flkty.select(photoId-1);
}
function setUrl(index) {
const albumName = document.getElementById("hidAlbumName").value;
const photoId = index + 1;
const newUrl = "/" + albumName + "/" + photoId;
window.history.pushState("object or string", "Title", newUrl);
}