TelerikMediaQuery - Add support for container queries

1 Answer 90 Views
Drawer MediaQuery
Rick
Top achievements
Rank 2
Iron
Iron
Rick asked on 08 Nov 2023, 05:19 PM
I find myself using css container queries a lot in conjunction with the TelerikDrawer.  I would really like to be able to use the MediaQuery control to set parameters based on the container size instead of the screen size.  

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 10 Nov 2023, 12:06 PM

Hi Rick,

This has been requested before (Feature request for CSS Container Queries), but currently there is not enough browser API to implement it.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Rick
Top achievements
Rank 2
Iron
Iron
commented on 10 Nov 2023, 02:35 PM

In the original question you were referenced the MediaQueryList.  

In the case of individual elements, why not try looking at the ResizeObserver.

Dimo
Telerik team
commented on 15 Nov 2023, 09:59 AM

Hi Rick,

Media query events fire once during resizing, when the CSS expression value toggles from true to false or vice-versa. On the other hand, the ResizeObserver fires events continuously during element resizing. This is very inefficient to handle in Blazor and requires throttling. As a result, a Blazor wrapper around ResizeObserver can never work smoothly like the "textbook" example on MDN.

So in other words, a potential Blazor component will:

  • Introduce a problem rather than solve one.
  • Duplicate existing browser functionality that one can use already.
  • Not provide any added value, except concealing a few lines of JavaScript code.

You may argue that bullets 2 and 3 may also apply to our MediaQuery component, but nevertheless we have it. The reasoning is:

  • Media-query-based responsive designs and algorithms are a lot more common.
  • The step-based MediaQuery behavior allows it to integrate more easily with other components and changes in their configuration.
  • We were reluctant about the MediaQuery component too, and we still are, to some extent.
Tags
Drawer MediaQuery
Asked by
Rick
Top achievements
Rank 2
Iron
Iron
Answers by
Dimo
Telerik team
Share this question
or