From 0434a61e7c97e9a3087cbe377ed9a619d581d835 Mon Sep 17 00:00:00 2001 From: heweishui Date: Tue, 18 Jun 2024 16:54:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3IntersectionObserver?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=E6=97=A0=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/api/wxml/index.tsx | 12 ++++++------ .../src/api/apis/wxml/IntersectionObserver.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/mini-program-example/src/pages/api/wxml/index.tsx b/examples/mini-program-example/src/pages/api/wxml/index.tsx index a2bac0117dee..6d0d30ee7e25 100644 --- a/examples/mini-program-example/src/pages/api/wxml/index.tsx +++ b/examples/mini-program-example/src/pages/api/wxml/index.tsx @@ -268,7 +268,7 @@ class IntersectionObserverTest extends React.Component { this.observer = undefined } this.observer = this.createIntersectionObserver(data) - TestConsole.consoleResult.call(this, this.observer, apiIndex) + TestConsole.consoleResult.call(this, "createIntersectionObserver:ok", apiIndex) }, }, { @@ -282,8 +282,8 @@ class IntersectionObserverTest extends React.Component { this.observer.disconnect() } this.observer = this.createIntersectionObserver() - this.observer.relativeTo('.scroll-view', data).observe('.ball', (res) => { - TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.observe', apiIndex) + this.observer.relativeTo('#IntersectionObserver', data).observe('.ball', (res) => { + TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.relativeTo', apiIndex) this.setState({ appear: res.intersectionRatio > 0, }) @@ -296,13 +296,13 @@ class IntersectionObserverTest extends React.Component { left: 0, }, func: (apiIndex, data) => { - TestConsole.consoleTest('IntersectionObserver.relativeTo') + TestConsole.consoleTest('IntersectionObserver.relativeToViewport') if (this.observer) { this.observer.disconnect() } this.observer = this.createIntersectionObserver() this.observer.relativeToViewport(data).observe('.ball', (res) => { - TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.observe', apiIndex) + TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.relativeToViewport', apiIndex) this.setState({ appear: res.intersectionRatio > 0, }) @@ -338,7 +338,7 @@ class IntersectionObserverTest extends React.Component { return ( IntersectionObserver测试 - + 先创建IntersectionObserver再滚动 diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts index 56d04aea5c18..4bd6a78f2c93 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts @@ -125,7 +125,7 @@ export class TaroHarmonyHybridIntersectionObserver implements Taro.IntersectionO } public relativeToViewport (margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver { - return this.relativeTo('.taro_page', margins) + return this.relativeTo('.taro_router', margins) } private _getCallbackByElement (element: Element) {