css-break

0.0.1 • Public • Published

css-break.js

A little script that runs in tandem with Modernizr to fire events when certain media queries are entered and exited due to a window resize.

Example

http://nicholasjohn.github.io/css-break/example/

Dependencies:

This module depends on a matchMedia polyfill for IE9 support. It is up to you to ensure this dependency exists. In the example, the script is contained within a IE9 conditional.

Usage:

Initialise breakpoints using cssBreak.add( '#mq', 'cssMediaQuery' /*, isIe */ ) :

cssBreak.add('small', '(min-width: 500px)')
cssBreak.add('medium', '(min-width: 800px)', true)

Call listeners using cssBreak.on( 'enter:#mq', callback ) or cssBreak.on( 'exit:#mq', callback ) :

cssBreak.on('enter:small', function () {
  // Do something for small screens here
})

cssBreak.on('exit:small', function () {
  // Undo the setup for small screens here
})

Licence

Licenced under the New BSD License

Readme

Keywords

none

Package Sidebar

Install

npm i css-break

Weekly Downloads

0

Version

0.0.1

License

BSD

Last publish

Collaborators

  • nicholasjohn