Resize JS is a tiny plugin to implement responsive events
npm install --save resizejs
import Resizable from 'resizejs';
const resp = new Resizable();
window.addEventListener('media.changed', () => {
const media = resp.getMedia();
const orientation = resp.getOrientation();
});
import Resizable from 'resizejs';
const resp = new Resizable({
enableOrientationChange: true
});
window.addEventListener('media.changed', () => {
const media = resp.getMedia();
const orientation = resp.getOrientation();
});
import Resizable from 'resizejs';
const resp = new Resizable({
breakpoints: {
mobile: 320,
mobileLarge: 414,
tablet: 768,
tabletLarge: 1024,
desktop: 1200
}
});
window.addEventListener('media.changed', () => {
const media = resp.getMedia();
const orientation = resp.getOrientation();
});
For example: Tablet to Desktop or Mobile to Tablet
import Resizable from 'resizejs';
const resp = new Resizable({
breakpoints: {
mobile: 320,
mobileLarge: 414,
tablet: 768,
tabletLarge: 1024,
desktop: 1200
}
});
window.addEventListener('basemedia.changed', () => {
const media = resp.getMedia();
const orientation = resp.getOrientation();
});
This library uses window.matchMedia
. To support old browsers please use a polyfill.