Sha256: c52875adb41345fa6e5dfc4c7e9bcc50403ea794ebfa4bb1954f539342b96716
Contents?: true
Size: 664 Bytes
Versions: 3
Compression:
Stored size: 664 Bytes
Contents
/* eslint-disable no-console */ export async function init() { const elements = document.querySelectorAll('[data-component]') if (elements.length < 1) return const { default: renderComponent } = await import(`./render_component`) Array.from(elements, ele => { const data = JSON.parse(ele.getAttribute('data-component')) let isVisible = false const observer = new IntersectionObserver(entries => { entries.forEach(entry => { if (!isVisible && entry.isIntersecting) { isVisible = true observer.unobserve(ele) renderComponent(ele, data) } }) }) observer.observe(ele) }) }
Version data entries
3 entries across 3 versions & 1 rubygems