W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2012

[whatwg] Supporting scrollTop and scrollLeft on the Canvas element

From: Charles Pritchard <chuck@jumis.com>
Date: Tue, 31 Jan 2012 14:35:45 -0800
Message-ID: <4F286CC1.2040007@jumis.com>
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

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:10 UTC