https://github.com/kanocomputing/layout-changes-js
Util to watch a DOM element's tree for resizes or content changes
https://github.com/kanocomputing/layout-changes-js
Last synced: about 1 year ago
JSON representation
Util to watch a DOM element's tree for resizes or content changes
- Host: GitHub
- URL: https://github.com/kanocomputing/layout-changes-js
- Owner: KanoComputing
- License: mit
- Created: 2015-03-19T16:51:57.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-19T17:44:39.000Z (about 11 years ago)
- Last Synced: 2025-02-13T13:08:42.575Z (over 1 year ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 1
- Watchers: 20
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### layout-changes.js
> Watch a DOM element's tree for layout changes and resizes, using a animationFrame (Shim) listener only until the element is on the DOM or event listener has been removed. May be used to handle layouts in which elements change frequently (CSS changes, content changes, images loaded, etc...)
#### Install
**With npm:**
```bash
# On your console, run
npm install --save layout-changes
```
```javascript
var layoutChanges = require('layout-changes');
// ..
```
**With bower:**
```bash
# On your console, run
bower install --save layout-changes
```
```html
```
```javascript
var layoutChanges = window.LayoutChanges
// ..
```
#### Usage
```javascript
var layoutChanges = require('layout-changes'),
element = document.getElementById('foobar');
layoutChanges.addListener(element, function (el) {
console.log('Element or an element\'s child has changed size or content', el);
});
```
#### Methods
* `addListener(element, callback)` Add a listener to given element to trigger callback
* `removeListener(element, callback)` Remove a previously assigned listener
#### Licence
Copyright (c) 2015 Kano Computing Ltd. - Released under the [MIT license](https://github.com/KanoComputing/layout-changes-js/blob/master/LICENSE)