Handling responsive behavior.
Execute given behavior under specific width, and execute rollback function when the screen width not in the specific width.
Just clone or download the zip of this repository
or via npm:
# npm install --save rwd-handler
or
$ yarn add rwd-handler
<script src='path/to/RwdHandler.min.js'></script>
or
// import in your .js file
import RwdHandler from 'rwd-handler';
- minWidth: number Minimum width of screen.
- maxWidth: number Maximum width of screen.
- behavior: function
The function going to execute under given screen width. - rollback: function
The function for returning behavior to previous state.
NOTE: If rollback function is given and an event listener is added in behavior, the event should call off() in rollback function. e.g.
const rwdHandler = new RwdHandler({
minWidth: 480,
maxWidth: 720,
behavior: rwdBehavior, //behavior function
rollback: rollback //rollback function
});
Execute rwd behavior under specific width, and execute rollback function when the screen width not in the specific width.
rwdHandler.execute();
Stop executing rwd behavior.
rwdHandler.stopExecute();
Change rwd detect width.
- minWidth: number Minimum width of screen.
- maxWidth: number Maximum width of screen.
rwdHandler.changeDetectWidth(0, 720);
Change rwd behavior.
- behavior: function
The function going to execute under given screen width.
rwdHandler.changeBehavior(behavior);
Change rwd rollback function.
- rollback: function
The function for returning behavior to previous state.
rwdHandler.changeRollback(rollback);
Change all handler config.
- options: object
RwdHandler options.
rwdHandler.changeConfig(options);