5.0.0 • Published 1 year ago
on-load v5.0.0
on-load
On load/unload events for DOM elements using a MutationObserver
usage
const onload = require('on-load')
const 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) 2023 Kyle Robinson Young. MIT License
5.0.0
1 year ago
4.0.2
5 years ago
4.0.1
6 years ago
4.0.0
6 years ago
3.4.1
6 years ago
3.4.0
6 years ago
3.3.4
6 years ago
3.3.3
6 years ago
3.3.2
6 years ago
3.3.1
7 years ago
3.3.0
7 years ago
3.2.3
7 years ago
3.2.2
7 years ago
3.2.1
7 years ago
3.2.0
8 years ago
3.1.1
8 years ago
3.1.0
8 years ago
3.0.0
8 years ago
2.2.0
8 years ago
2.1.1
8 years ago
2.1.0
8 years ago
2.0.0
8 years ago
1.0.0
8 years ago