Skip to content

shiyiya/scrolled-into-view

Repository files navigation

scrolled-into-view

Example
Determining whether the element into the document view.

Quick start

Place the following <script> near the end of your pages, right before the closing tag, to enable them.

<script src="your-path/scrolledintoview.min.js"></script>
<script>
  var listen = scrolledIntoView(
    'h1', // Element selector
    function(el) {
      // in
      el.classList.add('in')
    },
    function(el) {
      // out
      el.classList.remove('in')
    }
  )
  // remove listen
  listen.destroy()
</script>

API

/**
 *
 *
 * @export
 * @param {string} target
 * @param {function} intoCallback
 * @param {function} outCallback
 * @returns {object} new ScrolledIntoViewClass(...)
 */
scrolledIntoView(target, intoCallback, outCallback)

new scrolledIntoViewClass({
  target,
  intoCallback,
  outCallback
})

Releases

No releases published

Packages

No packages published