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.
http://nicholasjohn.github.io/css-break/example/
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.
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
})
Licenced under the New BSD License