mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 04:14:41 +00:00
fix: Headroom console error when no header
This commit is contained in:
1 parent
ab96e174c2
commit
0f612575bc
1 file changed
+12
-9
@@ -7,16 +7,19 @@
|
||||
|
||||
import Headroom from './_vendor/headroom.min.js';
|
||||
|
||||
let pageData = JSON.parse(document.getElementById('page-data').textContent);
|
||||
console.debug(`Use headroom on this page? ${pageData['use_headroom']}`);
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Get config
|
||||
let pageData = JSON.parse(document.getElementById('page-data').textContent);
|
||||
console.debug(`Use headroom on this page? ${pageData['use_headroom']}`);
|
||||
|
||||
if (pageData['use_headroom'] === true) {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Grab header element
|
||||
let myElement = document.querySelector('header');
|
||||
// Grab header element
|
||||
let $header = document.querySelector('header');
|
||||
|
||||
// Use Headroom on this page?
|
||||
if ($header && pageData['use_headroom'] === true) {
|
||||
// Construct an instance of Headroom, passing the header
|
||||
let headroom = new Headroom(myElement);
|
||||
let headroom = new Headroom($header);
|
||||
// Initialise Headroom
|
||||
headroom.init();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user