You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I was just working on a class that implements useIntersection, I wondered whether there is any way to pass the "threshold"-parameter to the underlying IntersectionObserver-class (see available options on MDN), as I was going to need some delay before appear and disappear-callbacks are being executed.
Turns out: It is indeed possible by simply adding "threshold" to the options-parameter of useIntersection (e.g. useIntersection(this, { threshold: 0.8 })). The official use-intersection docu does not mention anything about this possibility, instead it just mentions the stimulus-use-relevant options that are available. However, these options are simply passed further to new IntersectionObserver(...), as can be seen here and in the TypeScript-defintion of IntersectionOptions. The browser then probably simply "ignores" the options which are stimulus-use-specific, which is fine on the one hand, but a little bit verbose on the other.
I propose at least two ways to deal with this issue:
Add in the documentation of useIntersection the possibility to pass non-stimulus-use-specific options that are then passed further to create the internal IntersectionObserver instance (e.g. rootMargin or threshold).
Differentiate between options that are meant for useIntersection and those meant for IntersectionObserver.
The text was updated successfully, but these errors were encountered:
As I was just working on a class that implements
useIntersection
, I wondered whether there is any way to pass the "threshold"-parameter to the underlyingIntersectionObserver
-class (see available options on MDN), as I was going to need some delay beforeappear
anddisappear
-callbacks are being executed.Turns out: It is indeed possible by simply adding "threshold" to the options-parameter of
useIntersection
(e.g.useIntersection(this, { threshold: 0.8 })
). The official use-intersection docu does not mention anything about this possibility, instead it just mentions the stimulus-use-relevantoptions
that are available. However, these options are simply passed further tonew IntersectionObserver(...)
, as can be seen here and in the TypeScript-defintion ofIntersectionOptions
. The browser then probably simply "ignores" the options which are stimulus-use-specific, which is fine on the one hand, but a little bit verbose on the other.I propose at least two ways to deal with this issue:
useIntersection
the possibility to pass non-stimulus-use-specific options that are then passed further to create the internalIntersectionObserver
instance (e.g.rootMargin
orthreshold
).useIntersection
and those meant forIntersectionObserver
.The text was updated successfully, but these errors were encountered: