1function inView( element, customOffset = 0 ) { 2 3 if ( ! element ) { 4 return false; 5 } 6 7 const rect = element.getBoundingClientRect(); 8 const windowHeight = window.innerHeight || document.documentElement.clientHeight; 9 10 return rect.top >= 0 && rect.top <= windowHeight - customOffset; 11 12} 13 14function postCards() { 15 16 const overviews = document.querySelectorAll( '.latest-post, .post-overview, .tiles' ); 17 if ( ! overviews.length > 0 ) { 18 return; 19 } 20 21 overviews.forEach( ( overview ) => { 22 23 // Check if the element is in the viewport 24 const inViewCheck = inView( overview ); 25 if ( inViewCheck ) { 26 overview.classList.add( '--in-view' ); 27 } 28 29 } ); 30 31} 32 33function textBlockMedia() { 34 35 const textBlocks = document.querySelectorAll( '.textblock-media' ); 36 if ( ! textBlocks.length > 0 ) { 37 return; 38 } 39 40 textBlocks.forEach( ( textBlock ) => { 41 42 // Check if the element is in the viewport 43 const inViewCheck = inView( textBlock, 250 ); 44 if ( inViewCheck ) { 45 console.log( inViewCheck ); 46 textBlock.classList.add( '--in-view' ); 47 } 48 49 } ); 50 51} 52 53 54document.addEventListener( 'scroll', function () { 55 postCards(); 56 textBlockMedia(); 57} ); 58 59document.addEventListener( 'DOMContentLoaded', function () { 60 postCards(); 61 textBlockMedia(); 62} );
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.