htmx icon indicating copy to clipboard operation
htmx copied to clipboard

intersect trigger: add rootMargin option

Open bidoule opened this issue 2 years ago • 2 comments

Hello,

The rootMargin property for the Intersection Observer API allows to trigger the event before the element intersect into the view. It leads to a smoother web experience because the element is inserted before the user scroll into, and so it doesn't appear in front of the user.

It seems simple to add this option in the same way the options root and threshold are treated: https://github.com/bigskysoftware/htmx/blob/192df25b25060f41abdc72e93472fbc796f0db93/src/htmx.js#L1718

References: https://developer.mozilla.org/fr/docs/Web/API/Intersection_Observer_API https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin https://caniuse.com/mdn-api_intersectionobserver_rootmargin

bidoule avatar Apr 07 '23 09:04 bidoule

Would love to see this

RogierdeRuijter avatar Dec 21 '23 00:12 RogierdeRuijter

I need this option too please 😉

if (triggerSpec.rootMargin) {
    observerOptions.rootMargin = triggerSpec.rootMargin;
}

deltour-hugo avatar Jan 08 '24 16:01 deltour-hugo