Skip to content

Commit

Permalink
fix: 解决IntersectionObserver相关接口无效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
heweishui committed Jun 19, 2024
1 parent eeacd2c commit 0434a61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions examples/mini-program-example/src/pages/api/wxml/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
{
Expand All @@ -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,
})
Expand All @@ -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,
})
Expand Down Expand Up @@ -338,7 +338,7 @@ class IntersectionObserverTest extends React.Component {
return (
<View>
<View style={{ fontSize: '30px', textAlign: 'center' }}>IntersectionObserver测试</View>
<ScrollView className='scroll-view' scrollY>
<ScrollView id='IntersectionObserver' className='scroll-view' scrollY>
<View className='scroll-area' style={{ background: appear ? '#0f0' : '' }}>
<Text className='notice'>先创建IntersectionObserver再滚动</Text>
<View className='filling'></View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0434a61

Please sign in to comment.