AB-mediaQuery
AB-mediaQuery is the JavaScript side of Media Queries. It's a very simple, yet convenient tool for your developments.
Have a look at this Demonstration page (offline version is in the docs
folder).
This dependencie free and vanilla script is damn small: less than 1.3KB (uglyfied and GZipped)!
It's used in AB-interchange.
Version 1 is used on French websites of ENGIE and Gaz tarif règlementé.
Install
npm install --save ab-mediaquery
Setup
Import in your JS bundle (webpack, ES6, browserify...):
;
If you need a built version, it's in the dist
folder.
Init the script with:
ABplugins;
Other example:
ABplugins;
Usage
-
Get current breakpoints
ABmediaQuerycurrent;// return an array of current breakpoints -
Check specific breakpoint case
ABmediaQuery;// return a boolean -
JavaScript event
changed.ab-mediaquery
event is triggered when media query changes, you can listen to it:window;