←back to thread

471 points OuterVale | 4 comments | | HN request time: 0.896s | source
Show context
myfonj ◴[] No.42059426[source]
NB, that style does not play well with non-native DPI (e.g. when you have monitor set to 150% scale); to see it mapped to physical pixels, try running this in the browser's console:

    with(document.documentElement.style){
      transform = `scale(${ 1 / devicePixelRatio })`;
      transformOrigin = 'top left';
    }
(multiply the scale by whole number to get it "crisply zoomed").

Still not 100% perfect, but much closer to intended rendering, I guess.

replies(1): >>42068232 #
1. paulirish ◴[] No.42068232[source]
Wow, your use of `with` is both terrifying and super fresh. I love/hate it.
replies(1): >>42074566 #
2. phatskat ◴[] No.42074566[source]
I’ll be honest, I didn’t know JS had `with`…off to MDN
replies(1): >>42076059 #
3. myfonj ◴[] No.42076059[source]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

tl;dr is that `with` is a long deprecated statement that is good for casual "golfing" and raising eyebrows of JS-savvy folks. Does not work in the "use strict" mode (so in modules) and generally should not be used in any "real-world" production code, since it prevents many optimisations and could possibly make the code harder to grasp. But I guess for casual one-time console doodles it could be fine. Reportedly it is supported in all major JS engines, and I don't think it will be really removed in foreseeable future.

replies(1): >>42079794 #
4. phatskat ◴[] No.42079794{3}[source]
I read the MDN page on it right after my comment and it’s fascinating, and also very understandable why it’s a Bad Idea™