-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
63 lines (49 loc) · 1.64 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
$(document).ready(function() {
$('#mobile_btn').on('click', function () {
$('#mobile_menu').toggleClass('active');
$('#mobile_btn').find('i').toggleClass('fa-x');
});
const sections = $('section');
const navItems = $('.nav-item');
$(window).on('scroll', function () {
const header = $('header');
const scrollPosition = $(window).scrollTop() - header.outerHeight();
let activeSectionIndex = 0;
if (scrollPosition <= 0) {
header.css('box-shadow', 'none');
} else {
header.css('box-shadow', '5px 1px 5px rgba(0, 0, 0, 0.1');
}
sections.each(function(i) {
const section = $(this);
const sectionTop = section.offset().top - 96;
const sectionBottom = sectionTop+ section.outerHeight();
if (scrollPosition >= sectionTop && scrollPosition < sectionBottom) {
activeSectionIndex = i;
return false;
}
})
navItems.removeClass('active');
$(navItems[activeSectionIndex]).addClass('active');
});
ScrollReveal().reveal('#cta', {
origin: 'left',
duration: 2000,
distance: '20%'
});
ScrollReveal().reveal('.dish', {
origin: 'left',
duration: 2000,
distance: '20%'
});
ScrollReveal().reveal('#testimonial_chef', {
origin: 'left',
duration: 1000,
distance: '20%'
})
ScrollReveal().reveal('.feedback', {
origin: 'right',
duration: 1000,
distance: '20%'
})
});