(function () { 'use strict'; var nodes = Array.prototype.slice.call(document.querySelectorAll('.btp580-reveal')); var reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; var fallbackTimer = 0; function reveal(node) { if (node) node.classList.add('is-visible'); } function revealAll() { nodes.forEach(reveal); } if (!nodes.length) return; if (reducedMotion || !('IntersectionObserver' in window)) { revealAll(); return; } var safetyObserver = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { if (!entry.isIntersecting) return; reveal(entry.target); safetyObserver.unobserve(entry.target); }); }, { rootMargin: '38% 0px 38% 0px', threshold: 0 }); nodes.forEach(function (node) { safetyObserver.observe(node); }); /* * Content must never depend on animation for availability. The timed safety * release preserves the initial choreography while covering scrollbar jumps, * browser restoration and automated full-page capture. */ fallbackTimer = window.setTimeout(function () { revealAll(); safetyObserver.disconnect(); }, 3600); window.addEventListener('pageshow', function () { window.requestAnimationFrame(function () { nodes.forEach(function (node) { var rect = node.getBoundingClientRect(); if (rect.top < window.innerHeight * 1.25 && rect.bottom > -window.innerHeight * 0.25) reveal(node); }); }); }, { passive: true }); window.addEventListener('pagehide', function () { if (fallbackTimer) window.clearTimeout(fallbackTimer); }, { once: true }); }());