-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (39 loc) · 1.29 KB
/
index.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
// Sticky Navbar
window.addEventListener("scroll", function () {
var header = document.getElementById("header");
header.classList.toggle("sticky", this.window.scrollY > 0);
});
// navbar dropdown
document.addEventListener("DOMContentLoaded", function () {
const dropdownToggle = document.getElementById("dropdownNavbarLink");
const dropdownMenu = document.getElementById("dropdownNavbar");
dropdownToggle.addEventListener("click", function () {
dropdownMenu.classList.toggle("hidden");
});
});
document.addEventListener("DOMContentLoaded", function () {
const menuToggle = document.getElementById("menuToggle");
const navbarDropdown = document.getElementById("navbar-dropdown");
menuToggle.addEventListener("click", function () {
// Toggle the 'hidden' class on the menu
navbarDropdown.classList.toggle("hidden");
});
});
// Cursor
function loadCursorScript() {
var script = $("<script>").attr("src", "./cursor.js");
$("body").append(script);
}
function checkScreenSizeAndLoadScript() {
if (window.matchMedia("(min-width: 768px)").matches) {
loadCursorScript();
} else {
$('script[src="./cursor.js"]').remove();
}
}
checkScreenSizeAndLoadScript();
$(window).resize(checkScreenSizeAndLoadScript);
// Right click disabler
$("img").on("contextmenu", function (e) {
e.preventDefault();
});