Sha256: 8675ece9e0375674d2344a110670e6115587a75c36d23c89facf2f9053b3be2e

Contents?: true

Size: 708 Bytes

Versions: 6

Compression:

Stored size: 708 Bytes

Contents

/* eslint-disable no-console */

import renderComponent from `/proscenium-runtime/component_manager/render_component.js`

document.addEventListener('DOMContentLoaded', () => {
  const elements = document.querySelectorAll('[data-component]')

  if (elements.length < 1) return

  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

6 entries across 6 versions & 1 rubygems

Version Path
proscenium-0.1.0.alpha2-x86_64-linux lib/proscenium/runtime/component_manager/index.js
proscenium-0.1.0.alpha2-x86_64-darwin lib/proscenium/runtime/component_manager/index.js
proscenium-0.1.0.alpha2-arm64-darwin lib/proscenium/runtime/component_manager/index.js
proscenium-0.1.0.alpha1-x86_64-linux lib/proscenium/runtime/component_manager/index.js
proscenium-0.1.0.alpha1-x86_64-darwin lib/proscenium/runtime/component_manager/index.js
proscenium-0.1.0.alpha1-arm64-darwin lib/proscenium/runtime/component_manager/index.js