π» π² Simple and lightweight implementation to run javascript on viewport breakpoints
Define functions that run once when viewport enters the breakpoints
new LunchBreakpoints({
default: function() {
// any width larger than 1024
},
breakpoints: {
1024: function(){
// smaller than 1024 and bigger than 768
},
768: function() {
// smaller than 768
}
}
});
Whichever you prefer:
<script src="lunch-breakpoints.js"></script>
var LunchBreakpoints = window.returnExports;
npm install --save-dev lunch-breakpoints
var LunchBreakpoints = require('lunch-breakpoints');
import LunchBreakpoints from 'lunch-breakpoints';
Instantiate with new
:
new LunchBreakpoints(options);
where options...
parameter | description | ||||||||
---|---|---|---|---|---|---|---|---|---|
options |
Type: Object Default: { mobileFirst: false, throttle: false }
|
Lunch Breakpoints because lunch break and breakpoints