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.
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: