getMostVisibleObserverEntry()function

getMostVisibleObserverEntry(entries: IntersectionObserverEntry[]): IntersectionObserverEntry | undefined
ParamType
entriesIntersectionObserverEntry[]
The observer entries to compare (e.g. from an IntersectionObserver callback). required
Return
IntersectionObserverEntry | undefined
The entry with the largest visible ratio, or undefined when entries is empty.

Find the most-visible entry in a list of IntersectionObserverEntry objects.

  • Returns the entry with the highest intersectionRatio, or undefined for an empty list.

Examples

getMostVisibleObserverEntry(entries)?.target;