Spyes
Detect when a DOM element changes size or position.
Installation
Node.js
npm install spyes --save
Browser
Local
CDN unpkg
Example
const spyes = ; document ;
API
Spyes
Kind: global class
- Spyes
- new Spyes(element, [opts])
- .sizeIsChanged() ⇒
boolean
- .positionIsChanged() ⇒
boolean
- .watch() ⇒
Spyes
- .unwatch() ⇒
Spyes
- .onSize(callback) ⇒
Spyes
- .onPosition(callback) ⇒
Spyes
new Spyes(element, [opts])
Create instance
Param | Type | Default | Description |
---|---|---|---|
element | String | Element | element that you want watch |
|
[opts] | Object | configuration object |
|
[opts.autoWatch] | boolean | true | auto watch |
[opts.checkMs] | number | 50 | interval in milliseconds for every check |
[opts.unwatchAfterSize] | boolean | false | stop check after detect element resize |
[opts.unwatchAfterPosition] | boolean | false | stop check after detect element position |
boolean
spyes.sizeIsChanged() ⇒ Check if size is changed
Kind: instance method of Spyes
boolean
spyes.positionIsChanged() ⇒ Check if position is changed
Kind: instance method of Spyes
Spyes
spyes.watch() ⇒ Start watching
Kind: instance method of Spyes
Spyes
spyes.unwatch() ⇒ Stop watching
Kind: instance method of Spyes
Spyes
spyes.onSize(callback) ⇒ Fired when element changes size
Kind: instance method of Spyes
Param |
---|
callback |
Spyes
spyes.onPosition(callback) ⇒ Fired when element changes position
Kind: instance method of Spyes
Param |
---|
callback |
Changelog
You can view the changelog here
License
spyes is open-sourced software licensed under the MIT license