@bret/on-load
On load/unload events for DOM elements using a MutationObserver
Last updated 3 years ago by bret .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @bret/on-load 
SYNC missed versions from official npm registry.

on-load

NPM version build status Downloads js-standard-style

On load/unload events for DOM elements using a MutationObserver

usage

var onload = require('on-load')

var div = document.createElement('div')
onload(div, function (el) {
  console.log('in the dom')
}, function (el) {
  console.log('out of the dom')
})

// Will fire the onload
document.body.appendChild(div)

// ... some time later

// Will fire the onunload
document.body.removeChild(div)

API

onload(node, onloadFn, onunloadFn, [caller])

Pass a dom node to onload to have a onloadFn function fire when the dom node is added to the document dom and a onunloadFn fire when the dom node is removed from the document dom. Optionally a caller ID can be set to associate the onload/onunload hooks with a particular instance of of a dom node. This is commonly used when 'componentizing' dom nodes.

license

(c) 2016 Kyle Robinson Young. MIT License

Current Tags

  • 3.2.1                                ...           latest (3 years ago)

1 Versions

  • 3.2.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 0
Dependencies (1)
Dev Dependencies (7)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |