Re: Suggestion: Element.scrollParent

Just noticed that I haven't answered. Sorry for the delay

Use cases are when an element needs to be scroll-aware, and the container
can be many different elements.
Some examples:
- Sticky positioning
- Load sub elements when element becomes visible in scroll
- Animate element when visible in scroll
- Pause animations when element is out of sight
- Do something when scrolling to bottom

scrollParents array for nested scroll-enabled containers might be useful as
well, tough it can be easily achieved by recursively calling
scrollParent.scrollParent.scrollParent...

I prepared one example for a use of scrollParent:
https://jsfiddle.net/oriadam/n53asLs2


On Mon, Jun 12, 2017 at 4:41 PM, Mark <mark@heyimmark.com> wrote:

> Sounds like a cool feature. What are the use-cases? I'm genuinely curious
> as I've never came across a situation where I've needed this. Are there not
> any cases where there may be two parents in the hierarchy and you don't
> want the closest, but the one after it? Also, a more specific name would be
> better like "closestScrollParent" or similar. "scrollParent" is vague since
> there could be multiple "scrollParent"s technically.
>
> On Mon, Jun 12, 2017 at 8:14 AM Ori Adam <oria@blossom-kc.com> wrote:
>
>> Suggestion: Element.scrollParent
>> Returns the closest element which controls the position of current
>> element with a scroll.
>>
>>
>> This feature very useful in many cases, easy for browsers to implement
>> and hard for plugins such as jQueryUI to get it right.
>>
>> Thanks
>>
>>
>>

Received on Thursday, 29 June 2017 14:31:47 UTC