lynx: createIntersectionObserver() static method
lynx.createIntersectionObserver() 创建一个 IntersectionObserver。通过 options 配置回调条件。
语法
参数
component
传 { componentId: '' } 在当前 LynxView 中查找目标节点和参照节点。指定组件 ID 时,优先在该组件内查找,未找到时再查找整个 LynxView。
options
thresholds是[0, 1]范围内的相交比例阈值列表,默认[0]。后续检测中,相交比例达到、离开或跨过任一阈值时触发回调。initialRatio是首次检测的比较值,范围为[0, 1],默认0。默认仅在首次相交比例大于initialRatio时触发回调。开启页面开关enableIntersectionObserverInitialRatioCompatibility(Lynx 4.5 起支持)后,首次相交比例必须不同于initialRatio,且大于或等于至少一个配置阈值。observeAll在 Android、iOS 和 Harmony 上为保留选项,默认false。
返回值
示例
以下示例在当前 LynxView 中观察 #targetNode 与 #refNode 的相交情况。
不再需要观察时,调用 observer.disconnect()。
兼容性
LCD tables only load in the browser