intersect trigger: add rootMargin option
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
Would love to see this
I need this option too please 😉
if (triggerSpec.rootMargin) {
observerOptions.rootMargin = triggerSpec.rootMargin;
}