-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
executable file
·52 lines (42 loc) · 1.13 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
$(window).scroll(function () {
var scrollTop = $(window).scrollTop();
if (scrollTop > 100) {
$('.back-to-top').fadeIn();
} else {
$('.back-to-top').fadeOut();
}
});
$(document).ready(function() {
$(".menu-anchor").click(function (e) {
var goto = $(this).attr("href");
if (goto == "#factory") {
$(".menu").removeClass('active');
$("#hamburger-menu").removeClass('menu-open');
} else if (goto == "#workshop") {
$(".menu").removeClass('active');
$("#hamburger-menu").removeClass('menu-open');
}
});
var menu = document.querySelector(".menu"),
toggle = document.querySelector(".menu-toggle");
function toggleToggle() {
toggle.classList.toggle("menu-open");
};
function toggleMenu() {
menu.classList.toggle("active");
};
toggle.addEventListener("click", toggleToggle, false);
toggle.addEventListener("click", toggleMenu, false);
var $backToTopButton = $('<a href="#top" class="back-to-top">Go to top</a>')
.hide()
.css({
zIndex: 9999
});
$('body').append($backToTopButton);
$('.back-to-top').click(function () {
$('body, html').animate({
scrollTop: 0
}, 800);
return false;
});
});