req: retrieve active media-queries through javascript #39

Open
gebrits opened this Issue Jun 29, 2011 · 5 comments

Projects

None yet

3 participants

@gebrits
gebrits commented Jun 29, 2011

Not sure if this is the correct place for a feature request, but here it goes anyway:

Respond.js works great for bringing browser-independent support for media-queries.
However, when experimenting with responsive design I sometimes have the need to structure the DOM just a bit differently (using javascript) to achieve what I want (in addition to css-styling with media queries)

For this to work cross-browser too, to me the ideal situation would be to be able to request in javascript which media-queries are currently 'active' .

Modernizr.js for example has the mq() function which enables to ask for 'active' media-queries, but fails for IE8 and smaller for obvious reasons. I feel this feature would perfectly fit within Respond.js.

What do you think?

Thanks,
Geert-Jan

@scottjehl
Owner

I like this idea, thanks. I guess I could look at exposing the callback I use internally on resize, or maybe even dispatching events when a new query applies...

Since Modernizr optionally includes Respond.js in its builder, maybe we could map the mq() function to Respond's query parser when it's included. I'll talk to Paul :)

@gebrits
gebrits commented Jun 29, 2011

Great! I'll follow along :-) Thanks.

@paulirish
Collaborator

HMMMmm

  1. i like the feature req.

  2. i dont think we can bind a dependency to respond from mq() just yet. too early for that.

@scottjehl
Owner

oh no - I was thinking more like... respond monkeypatches mq() if anything... but it's just an idea. I'll plan to expose something either way.

Also, for now it's quite easy to base JS logic on window width and screen width without running media queries. In case someone's looking for a fix right away.

@gebrits
gebrits commented Jun 30, 2011

Yeah, that is what im doing at the moment. At the same time i often seem to feel more comfortable duplicating some elements in the dom and hide/show when appropriate using pure media queries, without js now im experimenting with it. Having said that, an integrated solution would be great. Thanks for the interest!

Sent from my iPhone

On 30 jun. 2011, at 20:29, scottjehlreply@reply.github.com wrote:

oh no - I was thinking more like... respond monkeypatches mq() if anything... but it's just an idea. I'll plan to expose something either way.

Also, for now it's quite easy to base JS logic on window width and screen width without running media queries. In case someone's looking for a fix right away.

Reply to this email directly or view it on GitHub:
#39 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment