관리-도구
편집 파일: slns-pillar-pages.js
/** * SLNS — PILLAR PAGES JS (shop listing + product details only) * 1. Detects which page we're on and tags <body> with * .slns-shop / .slns-pdp so the CSS background theme scopes cleanly. * 2. Scroll-in reveal for listing cards (re-runs after AJAX * filter / sort / pagination re-renders). */ (function () { 'use strict'; /* 1 · page detection → body class */ function tagPage() { const b = document.body; if (document.querySelector('.SearchParameters')) { b.classList.add('slns-shop'); } else if (document.querySelector('.add-to-cart-details-form')) { b.classList.add('slns-pdp'); } } /* 2 · listing card reveal */ function revealCards() { const cards = document.querySelectorAll('.product-with-bg:not([data-cxr])'); if (!cards.length) return; if (!('IntersectionObserver' in window)) { cards.forEach(c => { c.dataset.cxr = '1'; c.classList.add('cxr-in'); }); return; } const io = new IntersectionObserver(es => es.forEach(e => { if (!e.isIntersecting) return; e.target.classList.add('cxr-in'); io.unobserve(e.target); }), { threshold: 0.06, rootMargin: '0px 0px -24px 0px' }); cards.forEach((c, i) => { c.dataset.cxr = '1'; c.style.transitionDelay = `${(i % 4) * 80}ms`; io.observe(c); }); } function boot() { tagPage(); revealCards(); if ('MutationObserver' in window) { new MutationObserver(ms => { if (ms.some(m => [...m.addedNodes].some(n => n.nodeType === 1 && (n.matches?.('.product-with-bg') || n.querySelector?.('.product-with-bg')) ))) setTimeout(revealCards, 90); }).observe(document.body, { childList: true, subtree: true }); } } document.readyState !== 'loading' ? boot() : document.addEventListener('DOMContentLoaded', boot); window.addEventListener('load', () => setTimeout(revealCards, 300)); })();