question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_media doesn't evaluate dynamically

See original GitHub issue

The _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:

  1. The resize event: Listening to the event (ideally debounced), we can set the current screen dimensions after the window has been resized.
  2. The matchMedia() function: Using matchMedia, we can attach CSS media queries to the window 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
SamTolmaycommented, Aug 25, 2021

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

1reaction
Radiergummicommented, Aug 25, 2021

Maybe another solution for responsive layouts would be to have additional, size-dependent layout subkeys?

layout:
  span: 24
  md:
    span:
      12
  lg:
    span:
      8  

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found