Skip to content

Add support for scrollMargin field #749

@du33169

Description

@du33169

Is your feature request related to a problem? Please describe.

The IntersectionObserver API has supported a scrollMargin option since last year (MDN). It appears as a field hint when programming in an IDE because our IntersectionOptions extends the browser's IntersectionObserverInit interface (here).

However, only the explicitly defined fields are destructured and used in useInView.

As a result, scrollMargin is silently dropped and has no effect or warning.

Describe the solution you'd like

useInView (and other APIs) should forward scrollMargin to IntersectionObserver.

Describe alternatives you've considered

It might be better to preserve any unused IntersectionObserverInit fields when passing them through, in case there are future updates to the API.

Additional context

Version of react-intersection-observer: 10.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions