forked from kcc-nma-art128/final
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
executable file
·117 lines (92 loc) · 2.57 KB
/
scripts.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
var offsetHeight = 109;
var $mainNav = $(".main-nav");
// SMOOTH SCROLL
$(".main-nav a").click(function(e) {
e.preventDefault();
var $this = $(this);
var sectionId = $this.attr('href');
$('html, body').animate({
scrollTop: $(sectionId).offset().top
}, 750);
});
// STICKY NAV
var $navHeight = $mainNav.outerHeight();
var $headerHeight = 109;
// $('.nav-wrapper').height($navHeight);
$(window).scroll(function() {
if( $(this).scrollTop() > ($headerHeight) ) {
$mainNav.addClass("fixed");
} else {
$mainNav.removeClass("fixed");
}
});
if( $(window).scrollTop() > ($headerHeight) ) {
$mainNav.addClass("fixed");
}
var $searchbarToggle = $(".searchbar-toggle");
var $searchbarInput = $(".searchbar input");
$searchbarToggle.click(function(){
$searchbarInput.toggleClass("show");
})
// $( "#scroll-logo" ).scroll(function() {
// $("#small-logo").fadeIn();
// });
// var offsetHeight = 10;
// var $searchbarToggle = $(".searchbar-toggle")
//
// $(window).scroll(function() {
// var currentPosition = $(this).scrollTop();
//
//
// var top = 109;
//
// if (currentPosition >= top) {
// $mainNav.find('a').removeClass('active');
//
// $(this).addClass('active');
// $mainNav.find('a[href="#'+$(this).attr('id')+'"]').addClass('active');
// }
//
// });
// ACTIVE STATE
var $sections = $('#about, #menu, #gallery, #contact, #home');
$(window).scroll(function() {
var currentPosition = $(this).scrollTop();
$sections.each(function() {
var top = $(this).offset().top;
var bottom = top + $(this).height();
if (currentPosition >= top && currentPosition <= bottom) {
$mainNav.find('a').removeClass('active');
$sections.removeClass('active');
$(this).addClass('active');
$mainNav.find('a[href="#'+$(this).attr('id')+'"]').addClass('active');
}
});
});
// FLOAT LOGO
var $logo = $('.big-logo');
var $logoOffsetTop = $logo.offset().top;
$(window).scroll(function() {
if( $(this).scrollTop() > ($logoOffsetTop) ) {
$logo.addClass("fixed");
} else {
$logo.removeClass("fixed");
}
});
// SHOW/HIDE
var $ = jQuery.noConflict();
$(document).ready(function(){
$('#menubowls, #menufood').hide();
$('#a').click(function(){
$('#menudrinks').show();
$('#menubowls, #menufood').hide();
});
$('#b').click(function(){
$('#menubowls').show();
$('#menudrinks, #menufood').hide();
});
$('#c').click(function(){
$('#menufood').show();
$('#menudrinks, #menubowls').hide();
});
});