Skip to content

Commit

Permalink
fix(scroll): forceUpdate (#526)
Browse files Browse the repository at this point in the history
* fix: forceUpdate

* fix: rename

* fix: indexList foceUpdate
  • Loading branch information
tank0317 authored and dolymood committed Jun 24, 2019
1 parent 93eccbc commit 0068ade
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/components/index-list/index-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@
titleClick() {
this.$emit(EVENT_TITLE_CLICK, this.title)
},
forceUpdate(dirty) {
this.$refs.scroll.forceUpdate(dirty)
forceUpdate(dirty = false, nomore = false) {
this.$refs.scroll.forceUpdate(dirty, nomore)
dirty && this.$nextTick(() => {
this._calculateHeight()
})
Expand Down
44 changes: 26 additions & 18 deletions src/components/scroll/scroll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,24 @@
clickItem(item) {
this.$emit(EVENT_CLICK, item)
},
forceUpdate(dirty = false, nomore = false) {
async forceUpdate(dirty = false, nomore = false) {
if (this.isPullDownUpdating) {
return
}
if (this.pullDownRefresh && this.isPullingDown) {
this.isPullingDown = false
this._reboundPullDown(() => {
this._afterPullDown(dirty)
})
this.isPullDownUpdating = true
await this._waitFinishPullDown()
await this._waitResetPullDown(dirty)
this.isPullDownUpdating = false
} else if (this.pullUpLoad && this.isPullUpLoad) {
this.isPullUpLoad = false
this.scroll.finishPullUp()
this.pullUpNoMore = !dirty || nomore
dirty && this.refresh()
} else {
dirty && this.refresh()
}
dirty && this.refresh()
},
resetPullUpTxt() {
this.pullUpNoMore = false
Expand Down Expand Up @@ -472,19 +476,23 @@
this.isPullUpLoad = true
this.$emit(EVENT_PULLING_UP)
},
_reboundPullDown(next) {
_waitFinishPullDown(next) {
const {stopTime = DEFAULT_STOP_TIME} = this.pullDownRefresh
setTimeout(() => {
this.scroll.finishPullDown()
next()
}, stopTime)
return new Promise(resolve => {
setTimeout(() => {
this.scroll.finishPullDown()
resolve()
}, stopTime)
})
},
_afterPullDown(dirty) {
this.resetPullDownTimer = setTimeout(() => {
this.pullDownStyle = `top: -${this.pullDownHeight}px`
this.beforePullDown = true
dirty && this.refresh()
}, this.scroll.options.bounceTime)
_waitResetPullDown(dirty) {
return new Promise(resolve => {
this.resetPullDownTimer = setTimeout(() => {
this.pullDownStyle = `top: -${this.pullDownHeight}px`
this.beforePullDown = true
resolve()
}, this.scroll.options.bounceTime)
})
},
_getPullDownEleHeight() {
let pulldown = this.$refs.pulldown
Expand Down

0 comments on commit 0068ade

Please sign in to comment.