File: /virtual/moonarc/public_html/moonarc.shop/wp-content/themes/moonarc-child/assets/reveal.js
/* MOONARC — scroll reveal + sticky-header state (proof) */
(function () {
'use strict';
var body = document.body;
body.classList.add('moonarc-js');
var selectors = [
'.moonarc-hero__inner',
'.moonarc-head',
'.moonarc-card',
'.moonarc-reason',
'.moonarc-faq details',
'.moonarc-cta__inner'
];
var els = Array.prototype.slice.call(document.querySelectorAll(selectors.join(',')));
// stagger: 同じ親の中での出現順にわずかな遅延
els.forEach(function (el) {
var siblings = Array.prototype.slice.call(el.parentNode.children).filter(function (n) {
return n.classList && (
n.classList.contains('moonarc-card') ||
n.classList.contains('moonarc-reason')
);
});
var idx = siblings.indexOf(el);
if (idx > 0) { el.style.transitionDelay = (idx * 70) + 'ms'; }
});
if (!('IntersectionObserver' in window) || !els.length) {
els.forEach(function (el) { el.classList.add('is-revealed'); });
return;
}
var io = new IntersectionObserver(function (entries) {
entries.forEach(function (en) {
if (en.isIntersecting) {
en.target.classList.add('is-revealed');
io.unobserve(en.target);
}
});
}, { threshold: 0.12, rootMargin: '0px 0px -8% 0px' });
els.forEach(function (el) { io.observe(el); });
// sticky header: スクロールで背景を濃く
var header = document.querySelector('.moonarc-header');
if (header) {
var onScroll = function () {
header.classList.toggle('is-stuck', window.scrollY > 12);
};
onScroll();
window.addEventListener('scroll', onScroll, { passive: true });
}
})();