Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moszeed/nanoonload
tiny wrapper around mutation observe to detect added and removed elements
https://github.com/moszeed/nanoonload
Last synced: about 21 hours ago
JSON representation
tiny wrapper around mutation observe to detect added and removed elements
- Host: GitHub
- URL: https://github.com/moszeed/nanoonload
- Owner: moszeed
- License: mit
- Created: 2017-06-07T09:23:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-23T08:15:16.000Z (over 4 years ago)
- Last Synced: 2024-10-28T07:51:16.076Z (18 days ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# nanoonload
tiny wrapper around mutation observe to detect added and removed elements[![Join the chat at https://gitter.im/moszeed/nanoonload](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/moszeed/nanoonload?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## how to get
install from npmnpm i nanoonload
## how to use
### example, using body
```javascript
const nanoonload = require('nanoonload');const el = document.createElement('div');
el.className = 'test1';
el.textContent = 'addElement';nanoonload('div.test1', // can also be a nodeElement
(el) => { console.log('element is added'); },
(el) => { console.log('element is removed'); }
);document.body.appendChild(el);
document.body.removeChild(el);
```### example, with a targetNode
```javascript
const nanoonload = require('nanoonload');const baseElement = document.createElement('div');
baseElement.className = 'baseElement';const appendEl = document.createElement('div');
appendEl.className = 'addElement';nanoonload('div.addElement',
(el) => { console.log('element is added'); },
(el) => { console.log('element is removed'); }, {
targetNode: baseElement
}
);baseElement.appendChild(appendEl);
baseElement.removeChild(appendEl);
```