resizejs

0.0.1 • Public • Published

ResizeJS

Resize JS is a tiny plugin to implement responsive events

Install

npm install --save resizejs

Usage

Basic

import Resizable from 'resizejs';
 
const resp = new Resizable();
window.addEventListener('media.changed', () => {
    const media = resp.getMedia();
    const orientation = resp.getOrientation();
});

On orientation change

import Resizable from 'resizejs';
 
const resp = new Resizable({
    enableOrientationChange: true
});
window.addEventListener('media.changed', () => {
    const media = resp.getMedia();
    const orientation = resp.getOrientation();
});

Customize breakpoints

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();
});

Only when base media changes

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();
});

Note

This library uses window.matchMedia. To support old browsers please use a polyfill.

Package Sidebar

Install

npm i resizejs

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

29.7 kB

Total Files

9

Last publish

Collaborators

  • scssyworks