[whatwg] Supporting scrollTop and scrollLeft on the Canvas element

Floating a proposal here:

I'd like to see scrollTop and scrollLeft supported for the Canvas 
element. They would simply fire an onscroll event on the element, and do 
nothing else.
Many Canvas UIs use only one visible canvas layer, or otherwise, one 
main canvas layer.

It'd be quite handy to be able to use the scrollTop and scrollLeft 
setters, and as an author, hook into canvas.onscroll to identify when 
updates ought to be painted.

Currently, authors can create a large canvas, and place it in a div:
<div style="overflow: hidden">
<canvas>This can is larger than the div</canvas>
</div>

It would be great to be able to respond to scroll events, such as 
Element.scrollIntoViewIfNeeded and/or ctx.scrollPathIntoView,
and simplify the model in the future.

<div>
<canvas onscroll="repaint(scrollLeft,scrollTop)">This canvas is the same 
size as the div and responds to onscroll</canvas>
</div>

The values for scrollLeft and scrollTop would be in css pixels, as they 
are for other elements, and when set, they would trigger an onscroll 
event, as usual.


-Charles

Received on Tuesday, 31 January 2012 14:35:45 UTC