-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
134 lines (97 loc) · 2.93 KB
/
Copy pathscript.js
File metadata and controls
134 lines (97 loc) · 2.93 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/////////////
// SET CURRENT YEAR
const yearEl = document.querySelector(".year");
yearEl.textContent = new Date().getFullYear();
//////////////
///////////////////////
// MOBILE NAVIGATION BUTTONS SCRIPTING
// Make mobile navigation work
const navButton = document.querySelector(".btn-mobile-nav");
navButton.addEventListener("click", toggleMobileNav);
// Close mobile navigation on navigate
const mainNavLinks = document.querySelectorAll(".main-nav-link:link");
mainNavLinks.forEach(function (link) {
link.addEventListener("click", toggleMobileNav);
});
function toggleMobileNav() {
const headerEle = document.querySelector(".header");
const isNavOpen = headerEle.classList.toggle("nav-open");
document.body.classList.toggle("disable-scroll", isNavOpen);
}
////////////////////////
///////////////////////////////
// Sticky navigation
//////////////////////////////
const sectionHeroEl = document.querySelector('.section-hero')
const obs = new IntersectionObserver(function (entries) {
const ent = entries[0];
if (ent.isIntersecting === false) {
document.querySelector('body').classList.add('sticky-nav');
}
if (ent.isIntersecting === true) {
document.querySelector('body').classList.remove('sticky-nav');
}
}, {
// In the viewport
root: null,
threshold: 0,
rootMargin: '-80px'
});
obs.observe(sectionHeroEl);
//////////////////////////////
// // Fixing flexbox gap property missing in some Safari versions
// function checkFlexGap() {
// var flex = document.createElement("div");
// flex.style.display = "flex";
// flex.style.flexDirection = "column";
// flex.style.rowGap = "1px";
// flex.appendChild(document.createElement("div"));
// flex.appendChild(document.createElement("div"));
// document.body.appendChild(flex);
// var isSupported = flex.scrollHeight === 1;
// flex.parentNode.removeChild(flex);
// console.log(isSupported);
// if (!isSupported) document.body.classList.add("no-flexbox-gap");
// }
// checkFlexGap();
// https://unpkg.com/smoothscroll-polyfill@0.4.4/dist/smoothscroll.min.js
/*
.no-flexbox-gap .main-nav-list li:not(:last-child) {
margin-right: 4.8rem;
}
.no-flexbox-gap .list-item:not(:last-child) {
margin-bottom: 1.6rem;
}
.no-flexbox-gap .list-icon:not(:last-child) {
margin-right: 1.6rem;
}
.no-flexbox-gap .delivered-faces {
margin-right: 1.6rem;
}
.no-flexbox-gap .meal-attribute:not(:last-child) {
margin-bottom: 2rem;
}
.no-flexbox-gap .meal-icon {
margin-right: 1.6rem;
}
.no-flexbox-gap .footer-row div:not(:last-child) {
margin-right: 6.4rem;
}
.no-flexbox-gap .social-links li:not(:last-child) {
margin-right: 2.4rem;
}
.no-flexbox-gap .footer-nav li:not(:last-child) {
margin-bottom: 2.4rem;
}
@media (max-width: 75em) {
.no-flexbox-gap .main-nav-list li:not(:last-child) {
margin-right: 3.2rem;
}
}
@media (max-width: 59em) {
.no-flexbox-gap .main-nav-list li:not(:last-child) {
margin-right: 0;
margin-bottom: 4.8rem;
}
}
*/