/* Add custom Js code below */
document.addEventListener("DOMContentLoaded", function() { // تحميل مكتبات ثانوية بعد العرض }); /* ND BAnner (function () { if (window.__saggafScrollGallery96) return; window.__saggafScrollGallery96 = true; /* استبدل روابط الصور والشعار بعد رفع الملفات إلى سلة. */ const settings = { backgroundUrl: 'background.jpg', logoUrl: 'logo.svg', products: [ { image: '01-valentino-vg0015sa-001-53.webp', name: 'VALENTINO VG0015SA', description: '001 · مقاس 53' }, { image: '02-valentino-vg0033s-002-54.jpg', name: 'VALENTINO VG0033S', description: '002 · مقاس 54' }, { image: '03-valentino-vg0032s-005-53.webp', name: 'VALENTINO VG0032S', description: '005 · مقاس 53' }, { image: '04-cartier-ct0276s-001-60.webp', name: 'CARTIER CT0276S', description: '001 · مقاس 60' }, { image: '05-cartier-ct0220s-001-55.jpg', name: 'CARTIER CT0220S', description: '001 · مقاس 55' }, { image: '06-chanel-5515-54-c622-48.jpg', name: 'CHANEL 5515', description: 'C622/48 · مقاس 54' } ] }; function mountGallery() { if (document.querySelector('.nd96-gallery')) return; const root = document.querySelector('#nd96-gallery-root'); const main = document.querySelector('main'); if (!root && !main) return; const gallery = document.createElement('section'); gallery.className = 'nd96-gallery'; gallery.style.height = `${120 + settings.products.length * 70}vh`; gallery.setAttribute('aria-label', 'مجموعة نظارات اليوم الوطني من بصريات السقاف'); const productsMarkup = settings.products.map((item, index) => ` ${item.name} `).join(''); const detailsMarkup = settings.products.map((item, index) => ` `).join(''); const stepsMarkup = settings.products.map((_, index) => `0${index + 1}`).join(''); gallery.innerHTML = ` `; if (root) { root.replaceChildren(gallery); } else { main.prepend(gallery); } const productElements = Array.from(gallery.querySelectorAll('.nd96-gallery__product')); const detailElements = Array.from(gallery.querySelectorAll('.nd96-gallery__details')); const fill = gallery.querySelector('.nd96-gallery__fill'); const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)'); let frame = 0; function clamp(value, min, max) { return Math.min(Math.max(value, min), max); } function update() { frame = 0; if (reducedMotion.matches) return; const rect = gallery.getBoundingClientRect(); const distance = Math.max(gallery.offsetHeight - window.innerHeight, 1); const progress = clamp(-rect.top / distance, 0, 1); const position = progress * (settings.products.length - 1); const mobile = window.innerWidth < 768; productElements.forEach((element, index) => { const delta = index - position; const visibility = clamp(1 - Math.abs(delta) * 1.25, 0, 1); const x = delta * (mobile ? 70 : 115); const y = -50 + Math.abs(delta) * 4; const scale = .9 + visibility * .1; element.style.opacity = visibility.toFixed(3); element.style.transform = `translate3d(${x.toFixed(1)}px, ${y.toFixed(1)}%, 0) scale(${scale.toFixed(3)})`; }); detailElements.forEach((element, index) => { const delta = index - position; const visibility = clamp(1 - Math.abs(delta) * 1.7, 0, 1); element.style.opacity = visibility.toFixed(3); element.style.transform = `translate3d(0, ${(delta * 22).toFixed(1)}px, 0)`; }); fill.style.width = `${(progress * 100).toFixed(2)}%`; } function requestUpdate() { if (!frame) frame = requestAnimationFrame(update); } window.addEventListener('scroll', requestUpdate, { passive: true }); window.addEventListener('resize', requestUpdate, { passive: true }); update(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', mountGallery, { once: true }); } else { mountGallery(); } })();