wowchemy-headroom.js 799 B

12345678910111213141516171819202122232425
  1. /*************************************************
  2. * Wowchemy
  3. * https://github.com/wowchemy/wowchemy-hugo-themes
  4. *
  5. * Wowchemy Headroom
  6. **************************************************/
  7. import Headroom from './_vendor/headroom.min.js';
  8. document.addEventListener('DOMContentLoaded', function () {
  9. // Get config
  10. let pageData = JSON.parse(document.getElementById('page-data').textContent);
  11. console.debug(`Use headroom on this page? ${pageData['use_headroom']}`);
  12. // Grab header element
  13. let $header = document.querySelector('header');
  14. // Use Headroom on this page?
  15. if ($header && pageData['use_headroom'] === true) {
  16. // Construct an instance of Headroom, passing the header
  17. let headroom = new Headroom($header);
  18. // Initialise Headroom
  19. headroom.init();
  20. }
  21. });