-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
73 lines (63 loc) · 1.74 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$(function () {
// MagicGrid
// $(window).on("load", function () {
// // wait until all images load before calling magicgrid
// $(".img-container").show();
// let magicGrid = new MagicGrid({
// container: ".img-container",
// static: true,
// animate: true,
// useMin: true,
// maxColumns: 3,
// gutter: 10,
// });
// magicGrid.listen();
// });
// Modal
var modal = $("#modal");
var imgModal = $("#img-full");
$(".img-preview").click(function () {
var img = $(this);
modal.css("display", "block");
if (modal.scrollTop != 0) {
modal.scrollTop(0);
}
if (img.width() > img.height()) {
imgModal.css({ "max-height": "90%", "max-width": "85%" });
} else {
imgModal.css({ "max-height": "none", "max-width": "55%" });
}
imgModal.attr({ src: img.attr("src") });
$("#caption").html(img.attr("alt"));
});
modal.click(function () {
modal.css("display", "none");
});
// Scroll to top
$(window).scroll(function () {
var up = $(".fa-chevron-circle-up");
if ($(document).scrollTop() > 200) {
up.removeClass("popdown").addClass("popup");
up.show();
} else {
up.removeClass("popup").addClass("popdown");
if ($(document).scrollTop() < 180) {
up.hide();
}
}
});
$(".fa-chevron-circle-up").click(function () {
$(document).scrollTop(0);
});
// Mobile nav
$(".hamburger").click(function () {
$("#nav-items").addClass("responsive");
$(this).removeClass("active");
$(".nav-close").addClass("active");
});
$(".nav-close").click(function () {
$("#nav-items").removeClass("responsive");
$(this).removeClass("active");
$(".hamburger").addClass("active");
});
});