getMostVisibleObserverEntry()function
getMostVisibleObserverEntry(entries: IntersectionObserverEntry[]): IntersectionObserverEntry | undefined
| Param | Type | |
|---|---|---|
entries | IntersectionObserverEntry[] | 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, orundefinedfor an empty list.
Examples
getMostVisibleObserverEntry(entries)?.target;