on-media-query icon indicating copy to clipboard operation
on-media-query copied to clipboard

Thoughts on having a * catch all context?

Open xzyfer opened this issue 11 years ago • 3 comments

This is something we use in our projects. It essentially emulates matchMedia.addListener() but achieves the goal not repeating media queries in js and css.

I've got a proof of concept we're currently using here: https://github.com/xzyfer/js-media-queries/commit/6f1398a62f234ff2ce9f2bbf98c7cb938c1c6785

xzyfer avatar Jul 03 '13 01:07 xzyfer

Why can't you just do a query with all your mediaqueries

{
    context: ['mobile', 'skinny', 'desktop'],
    match: function() {
        ...
    },
    unmatch: function() {
        ...
    }
}

lukasoppermann avatar Sep 13 '14 07:09 lukasoppermann

The goal is for the js not to know anything about our media queries. We want to define out contexts in css with the rest of our media query and just have our js fire event/callback when we've transitioned between contexts.

xzyfer avatar Sep 14 '14 10:09 xzyfer

Ahh, okay, I see.

lukasoppermann avatar Sep 14 '14 10:09 lukasoppermann