- From: Mark <mark@heyimmark.com>
- Date: Fri, 30 Jun 2017 11:13:26 +0000
- To: Ori Adam <oria@blossom-kc.com>
- Cc: www-dom@w3.org
- Message-ID: <CAFfkm=KiQPPbW18hMx_=5nZEBZON4+8J6dDU2onmzAr23gnzRA@mail.gmail.com>
Hmmm… sticky positioning can be done by setting the element’s position property to sticky in CSS <https://developer.mozilla.org/en-US/docs/Web/CSS/position>. All of your other examples can be done with IntersectionObserver API <https://wicg.github.io/IntersectionObserver/>. Both can be used in browsers today. On Thu, Jun 29, 2017 at 10:31 AM Ori Adam <oria@blossom-kc.com> wrote: > 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 Friday, 30 June 2017 11:14:11 UTC