4 ms·
Wow that's a great tip, I did not know about that one, but it's going to be very useful for a UI I am about to start working on. In addition to requestAnimatio
by benjaminjackman 10y ago
Wow that's a great tip, I did not know about that one, but it's going to be very useful for a UI I am about to start working on.
In addition to requestAnimationFrame this could be very handy!
Are there any gotchas you have experienced in using this API that I should look out for?
- artursapek 10y agoJust look out for this not being supported and make sure your stuff still works. Eg, document.hidden might be undefined so don't initialize like this: doVisualUpdates = (document.hidden === true);
- minitech 10y agoWell, you’d typically want to do visual updates when document.hidden wasn’t true, which would work fine.
- ErikBjare 10y agoHe probably meant `(browser.hidden === false)` which wouldn't work if browser.hidden is undefined. Use == instead of === and it will work fine.
- minitech 10y ago`!document.hidden` would work, and it’s what most people would normally write already. `document.hidden == false` would not work; `false != undefined`.
- artursapek 10y agoNo, the opposite of that. If document.hidden === undefined, you don't want to use this optimization at all. What I was saying is, if you initialize doVisualUpdates as "document.hidden === true", in the case where it's undefined, you will never do visual updates.