3 ms·
Well, the website's down, so I can only speculate, but, how is the website to know the screen's refresh rate? If the site assumes, say, 60 Hz, but the rate is
by colanderman 12y ago
Well, the website's down, so I can only speculate, but, how is the website to know the screen's refresh rate? If the site assumes, say, 60 Hz, but the rate is actually 72 Hz, you'll see an odd "fading" effect between the two interlace frames at a rate of 12 Hz, which is very noticeable.
EDIT: Ah, I see he uses window.requestAnimationFrame [1] to sync with the frame rate, so this is not a problem.
[1] https://developer.mozilla.org/en-US/docs/Web/API/window.requestAnimationFrame https://developer.mozilla.org/en-US/docs/Web/API/window.requ...
- mikeash 12y agoIt doesn't actually have to know. There's a JavaScript API called requestAnimationFrame which asks the browser to invoke a callback for the next display refresh. Invoke requestAnimationFrame again from that callback, and you'll get a steady stream of callbacks at the display refresh rate, or whatever the browser thinks it is. Here's the relevant code from the demo: var work = (function() { var toggle = false; return function tester() { frame1.style.opacity = toggle?.5:1; frame2.style.opacity = toggle?1:.5; toggle=!toggle; requestAnimationFrame(tester); }; })(); requestAnimationFrame(work);