forked from ArvinH/netdb-web
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
77 lines (68 loc) · 1.79 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
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
74
75
76
77
// smooth scroll
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
// header scroll init
if($('body').scrollTop() > $('#banner').height()) {
$('#header').addClass("header-scroll");
} else {
$('#header').removeClass("header-scroll");
}
// header scroll event
$(window).on("scroll", function(e) {
if($('body').scrollTop() > $('#banner').height()) {
$('#header').addClass("header-scroll");
} else {
$('#header').removeClass("header-scroll");
}
});
// header menu init
if($('body').width() <= 700) {
$('#ul-desktop').hide();
$('#ul-tablet').show();
} else {
$('#ul-desktop').show();
$('#ul-tablet').hide();
}
// header menu resize event
$(window).resize(function() {
if($(this).width() <= 700) {
$('#ul-desktop').hide();
$('#ul-tablet').show();
} else {
$('#ul-desktop').show();
$('#ul-tablet').hide();
$('#menu').hide();
}
});
// header menu click event
$("#ul-tablet").click(function() {
$("#menu").show();
});
$("#menu-other").click(function() {
$("#menu-bar").animate({right: "-20em"}, 300, function(){
$(this).css("right", "0");
$("#menu").hide();
});
});
$("#menu-bar a").click(function() {
$("#menu-bar").animate({right: "-20em"}, 300, function(){
$(this).css("right", "0");
$("#menu").hide();
});
});
$(".menu-close").click(function() {
$("#menu-bar").animate({right: "-20em"}, 300, function(){
$(this).css("right", "0");
$("#menu").hide();
});
});