Skip to content

Commit b050a9f

Browse files
committed
fix: 解决IntersectionObserver相关接口无效问题
1 parent 9afb28a commit b050a9f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

examples/mini-program-example/src/pages/api/wxml/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class IntersectionObserverTest extends React.Component {
268268
this.observer = undefined
269269
}
270270
this.observer = this.createIntersectionObserver(data)
271-
TestConsole.consoleResult.call(this, this.observer, apiIndex)
271+
TestConsole.consoleResult.call(this, "createIntersectionObserver:ok", apiIndex)
272272
},
273273
},
274274
{
@@ -282,8 +282,8 @@ class IntersectionObserverTest extends React.Component {
282282
this.observer.disconnect()
283283
}
284284
this.observer = this.createIntersectionObserver()
285-
this.observer.relativeTo('.scroll-view', data).observe('.ball', (res) => {
286-
TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.observe', apiIndex)
285+
this.observer.relativeTo('#IntersectionObserver', data).observe('.ball', (res) => {
286+
TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.relativeTo', apiIndex)
287287
this.setState({
288288
appear: res.intersectionRatio > 0,
289289
})
@@ -296,13 +296,13 @@ class IntersectionObserverTest extends React.Component {
296296
left: 0,
297297
},
298298
func: (apiIndex, data) => {
299-
TestConsole.consoleTest('IntersectionObserver.relativeTo')
299+
TestConsole.consoleTest('IntersectionObserver.relativeToViewport')
300300
if (this.observer) {
301301
this.observer.disconnect()
302302
}
303303
this.observer = this.createIntersectionObserver()
304304
this.observer.relativeToViewport(data).observe('.ball', (res) => {
305-
TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.observe', apiIndex)
305+
TestConsole.consoleOnCallback.call(this, res, 'IntersectionObserver.relativeToViewport', apiIndex)
306306
this.setState({
307307
appear: res.intersectionRatio > 0,
308308
})
@@ -338,7 +338,7 @@ class IntersectionObserverTest extends React.Component {
338338
return (
339339
<View>
340340
<View style={{ fontSize: '30px', textAlign: 'center' }}>IntersectionObserver测试</View>
341-
<ScrollView className='scroll-view' scrollY>
341+
<ScrollView id='IntersectionObserver' className='scroll-view' scrollY>
342342
<View className='scroll-area' style={{ background: appear ? '#0f0' : '' }}>
343343
<Text className='notice'>先创建IntersectionObserver再滚动</Text>
344344
<View className='filling'></View>

packages/taro-platform-harmony-hybrid/src/api/apis/wxml/IntersectionObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class TaroHarmonyHybridIntersectionObserver implements Taro.IntersectionO
125125
}
126126

127127
public relativeToViewport (margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver {
128-
return this.relativeTo('.taro_page', margins)
128+
return this.relativeTo('.taro_router', margins)
129129
}
130130

131131
private _getCallbackByElement (element: Element) {

0 commit comments

Comments
 (0)