1document.addEventListener('theGemHeading.prepareAnimation', function(event) { 2 const element = event.target; 3 const animationName = element.dataset.animationName; 4 5 if (element && ['lines-slide-up', 'lines-slide-up-random'].includes(animationName)) { 6 theGemHeadingPrepareAnimation(element); 7 } 8}); 9 10function theGemHeadingPrepareAnimation(element) { 11 if (!element) return; 12 13 const isDesktop = window.innerWidth > 1024; 14 const isTablet = window.innerWidth <= 1024 && window.innerWidth >= 768; 15 const isMobile = window.innerWidth < 768; 16 17 /*if (element.classList.contains('animation-prepared')) return;*/ 18 if (element.classList.contains('thegem-heading-animate-disable-desktop') && isDesktop) return; 19 if (element.classList.contains('thegem-heading-animate-disable-tablet') && isTablet) return; 20 if (element.classList.contains('thegem-heading-animate-disable-mobile') && isMobile) return; 21 22 const animationName = element.dataset.animationName; 23 const animationDelay = parseInt(element.dataset.animationDelay) || 0; 24 const animationInterval = parseInt(element.dataset.animationInterval) || 0; 25 26 switch (animationName) { 27 case 'lines-slide-up': 28 case 'lines-slide-up-random': 29 const animationLineTagWrap = '<span class="thegem-heading-line-wrap">'; 30 31 let animationLineTag = function (index) { 32 let styles = ''; 33 if (animationName === 'lines-slide-up' && (animationDelay > 0 || animationInterval > 0)) { 34 styles = `animation-delay: ${(animationDelay + (animationInterval*(index+1)))}ms;`; 35 } 36 return '<span class="thegem-heading-line"' + (styles!== '' ? ' style="'+styles+'"' : '') + '>'; 37 }; 38 39 let nodes = element.childNodes; 40 let currentOffset = nodes[0].offsetTop; 41 let index = 0; 42 let idx = 0; 43 44 if (element.classList.contains('animation-prepared')) { 45 const originalNodes = []; 46 const lineWraps = element.querySelectorAll('.thegem-heading-line-wrap'); 47 48 lineWraps.forEach(wrap => { 49 const line = wrap.querySelector('.thegem-heading-line'); 50 if (line) { 51 while (line.firstChild) { 52 wrap.parentNode.insertBefore(line.firstChild, wrap); 53 } 54 } 55 wrap.remove(); 56 }); 57 58 element.classList.remove('animation-prepared'); 59 } 60 61 let html = animationLineTagWrap + animationLineTag(index); 62 63 for (let i = 0; i < nodes.length; i++) { 64 if (nodes[i].nodeType === 3) continue; 65 66 if (nodes[i].offsetTop > currentOffset + nodes[i].scrollHeight/2) { 67 index++; 68 html += '</span></span>' + animationLineTagWrap + animationLineTag(index); 69 currentOffset = nodes[i].offsetTop; 70 71 if (animationName === 'lines-slide-up-random') idx = 0; 72 } 73 74 if (animationName === 'lines-slide-up-random' && (animationDelay > 0 || animationInterval > 0)) { 75 nodes[i].style.animationDelay = (animationDelay + animationInterval*(idx+1)) + 'ms'; 76 } 77 78 html += nodes[i].outerHTML + ' '; 79 80 if (animationName === 'lines-slide-up-random') idx++; 81 } 82 83 html += '</span></span>'; 84 85 element.innerHTML = html; 86 87 break; 88 } 89 90 element.classList.add('animation-prepared'); 91}
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.