Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does devicePixelRatio change when the browser window is dragged between monitors?

With a retina Macbook Pro, it's possible to plug in an external monitor and you drag a browser window between the retina screen and the other, normal-DPI display.

Does this cause window.devicePixelRatio to dynamically change? And if so, is there any event I can monitor for when this happens?

I don't have one in front of me to test. I need to know because I might need to re-draw a canvas if it changes.

like image 675
callum Avatar asked Sep 27 '22 07:09

callum


1 Answers

Yes the devicePixelRatio changes, and you can detect it with matchMedia.

I think that you should have a look at this topic that give a more detailled answer for detect the change:

https://stackoverflow.com/a/29653772/3914736

like image 117
Allan Raquin Avatar answered Oct 18 '22 06:10

Allan Raquin