Skip to content

Add option to assume visible #163

Open
@ojanvafai

Description

@ojanvafai

When you call observe on an element, IntersectionObserver assumes it's hidden. So, if it's actually hidden, the callback never fires. In some cases, you want the callback to fire if it's hidden and not if it's visible. I expect there are also cases where you always want the callback to fire after you call observer.

I propose that we add a new value to the InstersectionObserver constructor's options argument to control this.

new IntersectionObserver(callback, { initialState: hidden|visible|none })

hidden == assume hidden and don't fire the callback if it is hidden in the frame after observe is called.
visible == the opposite of hidden
none == always fire the callback in the frame after observe is called

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions