22 lines
699 B
JavaScript
22 lines
699 B
JavaScript
import './stimulus_bootstrap.js';
|
|
import './styles/app.css';
|
|
|
|
// Delikatne odsłanianie sekcji przy scrollu.
|
|
const io = new IntersectionObserver((entries) => {
|
|
for (const entry of entries) {
|
|
if (entry.isIntersecting) {
|
|
entry.target.classList.add('is-visible');
|
|
io.unobserve(entry.target);
|
|
}
|
|
}
|
|
}, { threshold: 0.12 });
|
|
|
|
function initReveal() {
|
|
document.querySelectorAll('.reveal:not(.is-visible)').forEach((el) => io.observe(el));
|
|
}
|
|
|
|
// Ten plik ładuje się jako moduł (defer), więc DOM jest już sparsowany.
|
|
// Startujemy od razu, a przy nawigacji Turbo ponawiamy obserwację.
|
|
initReveal();
|
|
document.addEventListener('turbo:load', initReveal);
|