1const config = { 2 // selector 3 fadeInUpSelector: '.js-fadeIn', 4 5 // class name 6 stateClassName: 'is-active', 7}; 8 9export const setFadeIn = () => { 10 const { fadeInUpSelector, stateClassName } = config; 11 12 /** @type {NodeListOf<HTMLElement>} ãã§ã¼ãã¤ã³å¯¾è±¡ã®è¦ç´ */ 13 const items = document.querySelectorAll(fadeInUpSelector); 14 15 if (!items.length) { 16 return; 17 } 18 19 const observer = new IntersectionObserver( 20 (entries, obs) => { 21 entries.forEach(({ isIntersecting, target, boundingClientRect }) => { 22 // ç»é¢ã«å¯¾è±¡ãå ¥ã£ããis-activeã¯ã©ã¹ä»ä¸ 23 if (isIntersecting) { 24 target.classList.add(stateClassName); 25 obs.unobserve(target); 26 } 27 28 // ãã§ã«é鿏ã¿ï¼ç»é¢ããä¸ï¼ãªãå³è¡¨ç¤º 29 if (!isIntersecting && boundingClientRect.bottom < 0) { 30 target.classList.add(stateClassName); 31 obs.unobserve(target); 32 } 33 }); 34 }, 35 { 36 threshold: 0.3, //è¦ç´ ã®30%ãè¦ãããçºç« 37 } 38 ); 39 40 items.forEach((item) => observer.observe(item)); 41};
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.