Skip to content

Commit

Permalink
fix(wx-react-native): 修复FlatList onReachEnd多次调用的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ykforerlang committed Aug 6, 2019
1 parent 7ca826f commit 4c19656
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ Component({
return
}

if (this.compInst.props.data === this.endReachedInvokeData) {
return
}
const query = wx.createSelectorQuery().in(this)
query.select('#container').boundingClientRect((res) => {
const height = res.height
if (this.lastHeight === height) return


this.endReachedInvokeData = this.compInst.props.data
const method = getPropsMethod(this, 'onEndReached')
method && method()
this.lastHeight = height
const method = getPropsMethod(this, 'onEndReached')
method && method()
}).exec()
}
},
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
lower-threshold="{{100}}"
scroll-into-view="{{index_id}}"
>
<view style="{{contentContainerStyle}}min-height: calc(100% + {{onRefreshPassed ? 80 : 0}}px)">
<view id="container" style="{{contentContainerStyle}}min-height: calc(100% + {{onRefreshPassed ? 80 : 0}}px)">
<view
wx:if="{{onRefreshPassed}}"
style="height:80px;align-items:center;justify-content:center;"
Expand Down

0 comments on commit 4c19656

Please sign in to comment.