Re: [csswg-drafts] [cssom-view] Consider adding Element.scrollParent

Could you describe exactly what you really want? And include some usecases for this? Also, would it be useful to handle horizontal and vertical scrolling differently?

Looking at [the "workaround"](https://github.com/jquery/jquery-ui/blob/74f8a0ac952f6f45f773312292baef1c26d81300/ui/scroll-parent.js) in jQuery UI, it seems that it just checks the property of `overflow`? Is that enough for the usecases? I mean, having `overflow: auto` doesn't mean the element would have scrollbar, let alone whether it would be scrollable. (Actually having `overflow: hidden` doesn't even mean the element being not scrollable given that author can implement custom scrollbar with setting overflow to hidden.)

Also note that, there are several issues with the function in jQuery UI as far as I can tell:
1. It assumes that an element with `position: absolute` wouldn't be scrolled by any static ancestor, which is false, because when you don't specify top/bottom/left/right, the element would be attached to where it would be if it is static-positioned, and thus would be scrolled by a static ancestor.
2. In addition to the case above, absolutely-positioned and fixed-positioned elements would also be scrolled by ancestor which "acts as a containing block for absolutely positioned and fixed positioned descendants". See [CSS Containment spec](https://drafts.csswg.org/css-contain/#containment-layout) for example.
3. Except the cases above, fixed-positioned element shouldn't have scroll parent otherwise. It should really return null rather than the document.

And actually, this isn't going to be "easy" for browsers to implement. Browsers may end up just having a function like what you would have in JavaScript, which tries to walk up through the element tree and check relevant properties. The only thing which may make browsers be able to handle more elegantly is that they can reuse some checking logic with some existing code. But that really depends on how this would be specified.

-- 
GitHub Notification of comment by upsuper
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1522#issuecomment-307669912 using your GitHub account

Received on Monday, 12 June 2017 01:14:08 UTC