1// fade_move.js 2// å¯¾è±¡ï¼ 3// - ãã§ã¼ãï¼.fade-in / .fade-in-up / .fade-in-left / .fade-in-right / .selif 4// - ã©ã¤ã³é 次ï¼è¦ªã .line ã®åè¦ç´ 5// - è¦åºãæ¼åºï¼.move â .animate ä»ä¸ 6// ä»ä¸ã¯ã©ã¹ï¼ 7// - ãã§ã¼ã表示ï¼.is-visible 8// - è¦åºãæ¼åºï¼.animate 9 10(function () { 11 function initFadeMove() { 12 const fadeTargets = document.querySelectorAll( 13 '.fade-in, .fade-in-up, .fade-in-left, .fade-in-right, .selif' 14 ); 15 const moveTargets = document.querySelectorAll('.move'); 16 17 const allTargets = Array.prototype.slice.call(fadeTargets) 18 .concat(Array.prototype.slice.call(moveTargets)); 19 20 if (!allTargets.length) return; 21 22 // åããæ¸ããè¨å®ã®ã¦ã¼ã¶ã¼é æ ® 23 if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) { 24 fadeTargets.forEach(el => el.classList.add('is-visible')); 25 moveTargets.forEach(el => el.classList.add('animate')); 26 return; 27 } 28 29 // IntersectionObserver é対å¿ãã©ã¼ã«ãã㯠30 if (!('IntersectionObserver' in window)) { 31 fadeTargets.forEach(el => el.classList.add('is-visible')); 32 moveTargets.forEach(el => el.classList.add('animate')); 33 return; 34 } 35 36 const observer = new IntersectionObserver(function (entries, obs) { 37 entries.forEach(function (entry) { 38 if (!entry.isIntersecting) return; 39 40 const el = entry.target; 41 42 // A) .move â è¦åºãç¨ã¢ãã¡ 43 if (el.classList.contains('move')) { 44 el.classList.add('animate'); 45 } 46 // B) 親ã .line â é æ¬¡ãã§ã¼ã 47 else if (el.parentElement && el.parentElement.classList.contains('line')) { 48 const items = Array.prototype.slice.call(el.parentElement.children); 49 const index = items.indexOf(el); 50 const delay = index * 500; // 0.5ç§ã㤠51 52 setTimeout(function () { 53 el.classList.add('is-visible'); 54 }, delay); 55 } 56 // C) é常ãã§ã¼ã 57 else { 58 el.classList.add('is-visible'); 59 } 60 61 obs.unobserve(el); 62 }); 63 }, { 64 root: null, 65 rootMargin: '0px', 66 threshold: 0.1 67 }); 68 69 allTargets.forEach(function (el) { 70 observer.observe(el); 71 }); 72 } 73 74 if (document.readyState === 'loading') { 75 document.addEventListener('DOMContentLoaded', initFadeMove, { passive: true }); 76 } else { 77 initFadeMove(); 78 } 79})();
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.