Skip to content

Pass more data back to callbacks #227

Description

@mehulkar

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions