MatchMedia flakey in Firefox?

I am trying to use window.matchMedia to request a browser and move the div#move_me_around when the browser screen changes below a certain threshold. It works great in Chrome, Safari, and only occasionally in Firefox .

This is what I am trying to understand. I tested Firefox and has a window.matchMedia object, a mediaQueryList object, which itself has an addListener method.

Half of the time the event is fired and it works, and the other half does not work at all.

 # CoffeeScript $(document).ready -> mql = window.matchMedia 'screen and (max-width: 600px)' $move_me_around = ($ "#move_me_around") mql_handler = (mql) -> if mql.matches is true $move_me_around .appendTo("#sidebar") else $move_me_around .prependTo("#center_column") mql_handler(mql) mql.addListener (mql) -> mql_handler(mql) 
+4
source share

Source: https://habr.com/ru/post/1399073/


All Articles