title: Taro.createIntersectionObserver(component, options)

sidebar_label: createIntersectionObserver

Creates and returns an IntersectionObserver object instance. In a custom component or a page that contains a custom component, use this.createIntersectionObserver([options]) instead.

Reference

Type

  1. (component: Record<string, any>, options?: Option) => IntersectionObserver

Parameters

Option

Property Type Required Description
initialRatio number No The initial intersection ratio. If the intersection ratio detected at the time of the call is not equal to this value and reaches the threshold, the callback function of the listener is triggered.
observeAll boolean No Indicates whether to observe more than one target node simultaneously. If the value is set to “true”, the targetSelector of observe will select multiple nodes. (Note: selecting too many nodes at the same time will affect rendering performance.)
thresholds number[] No An array of values, which​contains all thresholds.

Sample Code

  1. const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })

API Support

API WeChat Mini-Program H5 React Native
Taro.createIntersectionObserver ✔️