1/** 2 * This script adds the header effects to the Altitude Pro Theme. 3 * 4 * @package Altitude Pro\JS 5 * @author StudioPress 6 * @license GPL-2.0-or-later 7 */ 8 9// From https://codepen.io/rikschennink/pen/yZYbwQ. 10 11// The debounce function receives our function as a parameter. 12const debounce = ( fn ) => { 13 14 // This holds the requestAnimationFrame reference, so we can cancel it if we wish. 15 let frame; 16 17 // The debounce function returns a new function that can receive a variable number of arguments. 18 return ( ...params ) => { 19 20 // If the frame variable has been defined, clear it now, and queue for next frame. 21 if ( frame ) { 22 cancelAnimationFrame( frame ); 23 } 24 25 // Queue our function call for the next frame. 26 frame = requestAnimationFrame( () => { 27 28 // Call our function and pass any params we received. 29 fn( ...params ); 30 }); 31 32 }; 33}; 34 35 36// Reads out the scroll position and stores it in the data attribute. 37// so we can use it in our stylesheets. 38const storeScroll = () => { 39 document.documentElement.dataset.scroll = window.scrollY; 40}; 41 42// Listen for new scroll events, here we debounce our `storeScroll` function. 43document.addEventListener( 'scroll', debounce( storeScroll ), { passive: true }); 44 45// Update scroll position for first time. 46storeScroll();
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.