_media doesn't evaluate dynamically
See original GitHub issueThe _media
operator returns information about the current screen dimensions, but doesn’t update them if the size changes during client runtime.
Ideally, the data would change if the window is resized, so block visibility could be controlled by media queries, similar to CSS.
There’s mainly two ways this can be achieved in modern browsers:
- The
resize
event: Listening to the event (ideally debounced), we can set the current screen dimensions after the window has been resized. - The
matchMedia()
function: UsingmatchMedia
, we can attach CSS media queries to thewindow
object and add event listeners that will be triggered if the query starts to match, or doesn’t match any longer. This allows to set named breakpoints (eg.sm
,lg
, etc.) in the application state.
By implementing those features combined, we could have up-to-date media query information available.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How to use dynamic variable in media query? - Stack Overflow
I have a few variables as the following, I want to use it in a media query, I trying to use #{viewport-$type} but...
Read more >Dynamic Audio Media not working - Power Platform Community
Solved: Hi all, so, I've got this scenario I've embedded some mp3's into the App as media. The infomation regarding the mp3's is...
Read more >Dynamic and Refresh - Mathematica Stack Exchange
The reason is that when the key is pressed, the DynamicModule sends the button action to the kernel for evaluation, waits for the...
Read more >A Complete Guide to CSS Media Queries
CSS Media queries are a way to target browser by certain characteristics, features, and user preferences, then apply styles based on those ...
Read more >Media Queries Level 5 - W3C
User agents must re-evaluate media queries in response to changes in the user environment that they're aware of, for example if the device...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is already a feature that we forgot to document properly 😅. You can see #685 for reference.
At least this means the schema we have is intuitive
Maybe another solution for responsive layouts would be to have additional, size-dependent layout subkeys?
The above example would simply add the layout classes with some kind of CSS media query, similar to how TailwindCSS does it. What do you think?