react-screen-onresize-mixin
v1.0.1
Published
Handle screen resizing with debounce delay.
Downloads
1
Maintainers
Readme
React screen resize listener mixin
A simple React mixin who handle screen resize detection from your React components.
Installation
npm install react-screen-onresize-mixin --save
Usage
// Import the mixin
import ScreenResizeMixin from 'react-screen-onresize-mixin';
const MyComponent = React.createClass({
mixins: [ ScreenResizeMixin ], // add it to your component
onScreenResize() {
// This function is executed
// each time the window is resized
}
});
By default the function onScreenResize
is executed after a delay of 250ms without resizing to prevent so many calls. This delay can be changed :
mixins: [ ScreenResizeMixin.delay( 500 ) ]