Sha256: 7737ea8f37c7b37aa8454e196f35d2a5916f9795fa5565716a1289d55fbc2abb

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

class FuturismElement extends HTMLElement {
  connectedCallback () {
    const options = {}

    this.observer = new IntersectionObserver((entries, observer) => {
      entries.forEach(
        (entry => {
          if (entry.isIntersecting) {
            this.dispatchAppearEvent(entry, observer)
          }
        }).bind(this)
      )
    }, options)

    this.observer.observe(this)
  }

  dispatchAppearEvent (entry, observer) {
    if (window.Futurism) {
      const evt = new CustomEvent('futurism:appear', {
        bubbles: true,
        detail: {
          target: entry.target,
          observer
        }
      })
      this.dispatchEvent(evt)
    } else {
      setTimeout(
        (() => {
          this.dispatchAppearEvent(entry, observer)
        }).bind(this),
        1
      )
    }
  }
}

customElements.define('futurism-element', FuturismElement)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
futurism-0.1.1 lib/templates/elements/futurism_element.js
futurism-0.1.0 lib/templates/elements/futurism_element.js