The onEnter and onExit callbacks currently receive the watched element as the first argument. It would be useful to receive the options that were passed when registering the callback as well.
My use case is currently only for testing. I want to test that the correct value is passed for the scrollableArea option. It's a bit hard to write a test that actually asserts the behavior of IntersectionObserver and its implementation of the root argument. Since my abstraction for IO is this addon, I could write my test case to the API provided here instead.
Something like this:
<div {{in-viewport onEnter=this.foo scrollableArea=".something"}}>
{{!--
function foo(element, options) {
assert.equal(options.scrollableArea, '.something');
}
--}}
I think this could be achieved by binding these options before adding them to rafAdmin or observerAdmin when adding the callbacks.
The
onEnterandonExitcallbacks currently receive the watched element as the first argument. It would be useful to receive the options that were passed when registering the callback as well.My use case is currently only for testing. I want to test that the correct value is passed for the
scrollableAreaoption. It's a bit hard to write a test that actually asserts the behavior ofIntersectionObserverand its implementation of therootargument. Since my abstraction for IO is this addon, I could write my test case to the API provided here instead.Something like this:
I think this could be achieved by binding these options before adding them to
rafAdminorobserverAdminwhen adding the callbacks.