0.1.0 • Published 9 years ago
mobx-respond v0.1.0
mobx-respond

Responsive web design script with mobx. The goal of this lib is to provide a CSS3 min/max-width media query like function in javascript, so you can perform different action in different size of screen. So you can do things easily like:
- show custom message when viewport is too small.
- jump to mobile version site when viewport is too small.
Installation
$ npm install --save mobx-respond
or
$ yarn add mobx-respondUse CDN
- Include mobx first https://unpkg.com/mobx/lib/mobx.umd.js
- Then include https://unpkg.com/mobx-respond/umd/mobx-respond.js
Then get the respond class:
// using ES6 modules
import Respond from 'mobx-respond'
// using CommonJS modules
var Respond = require('mobx-respond').Respond
// using CDN
var Respond = mobxRespond.Respond
var respond = new Respond()Usage
- construtor(config)
default config is
{
xs: [null, 767],
sm: [768, 991],
md: [992, 1199],
lg: [1200, null],
};Props
getterwidth- type:
number
Width of current viewport
getterheight- type:
number
Height of current viewport
getterXXX- type:
boolean
Whether current viewport satisfied the configuration of XXX
Demo
0.1.0
9 years ago