0.0.1 • Published 10 years ago

css-break v0.0.1

Weekly downloads
3
License
-
Repository
github
Last release
10 years ago

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