JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 102
  • Score
    100M100P100Q82707F
  • License MIT

Enable lifecycle events for DOM-elements: attached, detached, enteredView, leftView

Package Exports

  • lifecycle-events

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lifecycle-events) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Lifecycle-events

Polyfill-like lib providing lifecycle events for HTML elements: enteredView, leftView, attached and detached.

It is 2.1 kB gzipped.

Use as polyfill

Include lifecycle.min.js:

<script src="lifecycle.min.js"></script>
<script>lifecycle('*');</script>

Use customly:

Install browserify module:

$ npm install lifecycle-events

Code:

var lifecycle = require('lifecycle-events');


//Enable lifecycle events for the Node/NodeList passed
lifecycle.enable(element);
element.addEventListener('enteredView', function(){});
element.addEventListener('attached', function(){});


//Enable only viewport events
lifecycle.enableViewport('.item');


//Enable only mutation events within container passed
lifecycle.enableMutation('.item', '.feed');


//Disable lifecycle events for previously added selector
lifecycle.disable('*');


//Disable all lifecycle events
lifecycle.disable();

TODO

  • Optimize enabled selectors. For example, avoid extra enable if you have '*' enabled. And so on.

License

MIT