1'use strict'; 2 3document.addEventListener('DOMContentLoaded', () => { 4 // Get all "navbar-burger" elements 5 const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0); 6 7 // Check if there are any navbar burgers 8 if ($navbarBurgers.length > 0) { 9 10 // Add a click event on each of them 11 $navbarBurgers.forEach( el => { 12 el.addEventListener('click', () => { 13 // Get the target from the "data-target" attribute 14 const target = el.dataset.target; 15 const $target = document.getElementById(target); 16 17 // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu" 18 el.classList.toggle('is-active'); 19 $target.classList.toggle('is-active'); 20 }); 21 }); 22 } 23 24 // Animate some elements on scroll 25 var scroll = window.requestAnimationFrame || function(callback) { window.setTimeout(callback, 1000/60) }; 26 var elementsToShow = document.querySelectorAll('.show-on-scroll'); 27 function loop() { 28 elementsToShow.forEach(function (element) { 29 if (isElementInViewport(element)) { 30 element.classList.add('is-visible'); 31 } else { 32 element.classList.remove('is-visible'); 33 } 34 }); 35 scroll(loop); 36 } 37 loop(); 38 // Helper function from: http://stackoverflow.com/a/7557433/274826 39 function isElementInViewport(el) { 40 // special bonus for those using jQuery 41 if (typeof jQuery === "function" && el instanceof jQuery) { 42 el = el[0]; 43 } 44 var rect = el.getBoundingClientRect(); 45 return ( 46 (rect.top <= 0 47 && rect.bottom >= 0) 48 || 49 (rect.bottom >= (window.innerHeight || document.documentElement.clientHeight) && 50 rect.top <= (window.innerHeight || document.documentElement.clientHeight)) 51 || 52 (rect.top >= 0 && 53 rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)) 54 ); 55 } 56});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.