Re: [cssom-view] scrollMaxX/Y

On Fri, 22 Jun 2012 01:54:07 +0200, Robert O'Callahan  
<robert@ocallahan.org> wrote:

> Web authors want to detect when scrollable elements can be scrolled in a
> given direction,
> e.g.http://stackoverflow.com/questions/2059743/detect-elements-overflow-using-jquery
> http://stackoverflow.com/questions/4369990/scrollheight-property-in-firefox
> Often this means knowing what the maximum value is for
> scrollLeft/scrollTop. You can estimate this using scrollWidth -  
> clientWidth
> and scrollHeight - clientHeight, but that can give a slightly wrong  
> answer
> due to rounding if you're doing subpixel layout. For example, an element
> whose unrounded clientHeight is 1.4px and unrounded scrollHeight is 1.6px
> would compute scrollWidth - clientWidth = 1 although in fact scrollTop's
> maximum value is 0 (actually, whether scrollTop's maximum value is 0 or 1
> depends on how the UA handles scrolling with subpixel rendering, but 0  
> is a
> reasonable choice).
>
> It would be simpler and less error-prone to simply have a DOM attribute
> that returns the maximum values for scrollLeft/scrollTop. For the  
> viewport,
> Gecko has supported window.scrollMaxX/Y for a long time, but no-one else
> has this as far as I know.
>
> I propose adding scrollMaxX and scrollMaxY as read-only DOM attributes on
> Element, returning the maximum possible values for scrollLeft and  
> scrollTop
> respectively. They would of course be 0 for non-scrollable elements.
>
> For the bikeshedders out there, I think scrollLeftMax and scrollTopMax
> would also be acceptable names.

An alternative could be to expose subpixel values for scrollWidth and  
clientWidth (et al). IE supports this but requires opt-in:  
http://blogs.msdn.com/b/ie/archive/2012/02/17/sub-pixel-rendering-and-the-css-object-model.aspx

Would it be Web-compatible to expose subpixel values in CSSOM View?

(I don't object to adding scrollMaxX/Y. Maybe we should do both?)

-- 
Simon Pieters
Opera Software

Received on Friday, 19 April 2013 19:46:08 UTC