infiniscroll

1.1.0 • Public • Published

Infinite Scroll Widget

Create/decorate an element which loads more content automatically when the scroll position reaches either the top or bottom.

var infiniscroll = require('infiniscroll')
var el = infiniscroll('div', {
  fetchTop: function (cb) {
    el.insertBefore(renderMoreTop(), el.firstChild)
    cb()
  },
  fetchBottom: function (cb) {
    el.appendChild(renderMoreBottom())
    cb()
  }
})

Notes:

  • fetchTop and fetchBottom are optional
  • the first param may be a tagname, hyperscript template string, or existing DOM element
  • When the element scrolls away from the top, this adds a scrolled class to do custom styling

LICENSE

MIT

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i infiniscroll

      Weekly Downloads

      1

      Version

      1.1.0

      License

      MIT

      Last publish

      Collaborators

      • pfraze