Canvas Visibility API

Hello,

We have the following use case. The animation is performed at the 
specific frame rate and requires some computations be executed each 
frame. The frame painting is performed at requestAnimationFrame on the 
canvas and might take some time to do it, and it will be useful to not 
perform any painting at all to avoid unnecessary operations.

Is there an interest to add an API similar to Page Visibility [1] to the 
DOM elements (at least for canvas elements)? Basically to allow scripts 
to query visibility state of the particular DOM element and receive 
event notifications when the element is about to be visible/hidden (or 
even, if possible, "near-the-view"). Also, in the past I met multiple 
cases where event notifications about elements visibility could help 
illuminate bulky JavaScript solutions using resize/scroll event handlers 
that use offsetLeft/getBoundingClientRect/scrollX-style checks (e.g. 
pdf.js [2] or floating headers).

This proposal is somewhat similar to "support an element parameter to 
requestAnimationFrame()" issue [3]. However this solution doesn't let us 
to detect if the element is about to be hidden.

Thank you,
Yury Delendik

   [1] 
https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html
   [2] http://mozilla.github.io/pdf.js/web/viewer.html
   [3] http://www.w3.org/2010/webperf/track/issues/4
   [4] https://bugzilla.mozilla.org/show_bug.cgi?id=903575

Received on Tuesday, 13 August 2013 15:41:13 UTC