spyes
v1.0.1
Published
Detect when a DOM element changes size or position
Downloads
4
Maintainers
Readme
Spyes
Detect when a DOM element changes size or position.
Installation
Node.js
npm install spyes --save
Browser
Local
<script src="node_modules/spyes/dist/spyes.min.js"></script>
CDN unpkg
<script src="https://unpkg.com/spyes/dist/spyes.min.js"></script>
Example
const spyes = require('spyes');
new spyes(document.getElementById('my-element'))
.onSize((newSize, oldSize)=> console.log('size changed', newSize, oldSize))
.onPosition((newPosition, oldPosition)=> console.log('position changed', newPosition, oldPosition));
API
Spyes
Kind: global class
new Spyes(element, [opts])
Create instance
spyes.sizeIsChanged() ⇒ boolean
Check if size is changed
Kind: instance method of Spyes
spyes.positionIsChanged() ⇒ boolean
Check if position is changed
Kind: instance method of Spyes
spyes.watch() ⇒ Spyes
Start watching
Kind: instance method of Spyes
spyes.unwatch() ⇒ Spyes
Stop watching
Kind: instance method of Spyes
spyes.onSize(callback) ⇒ Spyes
Fired when element changes size
Kind: instance method of Spyes
spyes.onPosition(callback) ⇒ Spyes
Fired when element changes position
Kind: instance method of Spyes
Changelog
You can view the changelog here
License
spyes is open-sourced software licensed under the MIT license
Author
Fabio Ricali