Skip to content

Commit 085919b

Browse files
committed
Minor clean-up to _main.js, plus some more comments
1 parent c4a2829 commit 085919b

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

assets/js/_main.js

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,39 +82,36 @@ document.addEventListener("readystatechange", () => {
8282
========================================================================== */
8383

8484
$(document).ready(function () {
85-
setTheme();
86-
87-
// if user hasn't chosen a theme, follow OS changes
88-
window
89-
.matchMedia('(prefers-color-scheme: dark)')
90-
.addEventListener("change", (e) => {
91-
if (!localStorage.getItem("theme")) {
92-
setTheme(e.matches ? "dark" : "light");
93-
}
94-
});
85+
// SCSS SETTINGS - These should be the same as the settings in the relevant files
86+
const scssLarge = 925; // pixels, from /_sass/_themes.scss
87+
const scssMastheadHeight = 70; // pixels, from the current theme (e.g., /_sass/theme/_default.scss)
9588

89+
// If the user hasn't chosen a theme, follow the OS preference
90+
setTheme();
91+
window.matchMedia('(prefers-color-scheme: dark)')
92+
.addEventListener("change", (e) => {
93+
if (!localStorage.getItem("theme")) {
94+
setTheme(e.matches ? "dark" : "light");
95+
}
96+
});
97+
98+
// Enable the theme toggle
9699
$('#theme-toggle').on('click', toggleTheme);
97100

98-
// These should be the same as the settings in _variables.scss
99-
const scssLarge = 925; // pixels
100-
101-
// Sticky footer
101+
// Enable the sticky footer
102102
var bumpIt = function () {
103103
$("body").css("margin-bottom", $(".page__footer").outerHeight(true));
104-
},
105-
didResize = false;
106-
107-
bumpIt();
108-
104+
}
109105
$(window).resize(function () {
110106
didResize = true;
111107
});
112108
setInterval(function () {
113109
if (didResize) {
114110
didResize = false;
115111
bumpIt();
116-
}
117-
}, 250);
112+
}}, 250);
113+
var didResize = false;
114+
bumpIt();
118115

119116
// FitVids init
120117
fitvids();
@@ -132,9 +129,9 @@ $(document).ready(function () {
132129
}
133130
});
134131

135-
// init smooth scroll, this needs to be slightly more than then fixed masthead height
132+
// Init smooth scroll, this needs to be slightly more than then fixed masthead height
136133
$("a").smoothScroll({
137-
offset: -75, // needs to match $masthead-height
134+
offset: -scssMastheadHeight,
138135
preventDefault: false,
139136
});
140137

assets/js/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)