Skip to main content
Version: 3.x

Taro.createIntersectionObserver(component, options)

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

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

Parameters

Option

PropertyTypeRequiredDescription
initialRationumberNoThe 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.
observeAllbooleanNoIndicates 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.)
thresholdsnumber[]NoAn array of values, which​contains all thresholds.

Sample Code

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

API Support

APIWeChat Mini-ProgramH5React Native
Taro.createIntersectionObserver✔️