JoshBarr / on-media-query

A neat way to trigger JS when media queries change. No jQuery required.
283 stars 33 forks source link

Add a * select to match all changes. Fixes #23. #25

Open xzyfer opened 11 years ago

xzyfer commented 11 years ago

This pull request adds a * context that acts as a catch all.

var queries = [
    {
        context: 'mobile',
        match: function() {
            console.log('Mobile callback. Maybe hook up some tel: numbers?');
        },
        unmatch: function() {
            // We're leaving mobile.    
        }
    },
    {
        context: '*',
        match: function() {
            console.log('Changed breakpoint.');
        }
    }
];
// Go!
MQ.init(queries);
</script>

Now Changed breakpoint. will also be logged to the console any time any break point is matched.

xzyfer commented 11 years ago

Fixes #23.