0.0.1 • Published 5 years ago

resizejs v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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.