提交 99b5e6bb 编写于 作者: T tank0317 提交者: doly mood

fix(scroll): forceUpdate (#526)

* fix: forceUpdate

* fix: rename

* fix: indexList foceUpdate
上级 d93fe2e3
...@@ -169,8 +169,8 @@ ...@@ -169,8 +169,8 @@
titleClick() { titleClick() {
this.$emit(EVENT_TITLE_CLICK, this.title) this.$emit(EVENT_TITLE_CLICK, this.title)
}, },
forceUpdate(dirty) { forceUpdate(dirty = false, nomore = false) {
this.$refs.scroll.forceUpdate(dirty) this.$refs.scroll.forceUpdate(dirty, nomore)
dirty && this.$nextTick(() => { dirty && this.$nextTick(() => {
this._calculateHeight() this._calculateHeight()
}) })
......
...@@ -306,20 +306,24 @@ ...@@ -306,20 +306,24 @@
clickItem(item) { clickItem(item) {
this.$emit(EVENT_CLICK, 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) { if (this.pullDownRefresh && this.isPullingDown) {
this.isPullingDown = false this.isPullingDown = false
this._reboundPullDown(() => { this.isPullDownUpdating = true
this._afterPullDown(dirty) await this._waitFinishPullDown()
}) await this._waitResetPullDown(dirty)
this.isPullDownUpdating = false
} else if (this.pullUpLoad && this.isPullUpLoad) { } else if (this.pullUpLoad && this.isPullUpLoad) {
this.isPullUpLoad = false this.isPullUpLoad = false
this.scroll.finishPullUp() this.scroll.finishPullUp()
this.pullUpNoMore = !dirty || nomore this.pullUpNoMore = !dirty || nomore
dirty && this.refresh()
} else {
dirty && this.refresh()
} }
dirty && this.refresh()
}, },
resetPullUpTxt() { resetPullUpTxt() {
this.pullUpNoMore = false this.pullUpNoMore = false
...@@ -472,19 +476,23 @@ ...@@ -472,19 +476,23 @@
this.isPullUpLoad = true this.isPullUpLoad = true
this.$emit(EVENT_PULLING_UP) this.$emit(EVENT_PULLING_UP)
}, },
_reboundPullDown(next) { _waitFinishPullDown(next) {
const {stopTime = DEFAULT_STOP_TIME} = this.pullDownRefresh const {stopTime = DEFAULT_STOP_TIME} = this.pullDownRefresh
setTimeout(() => { return new Promise(resolve => {
this.scroll.finishPullDown() setTimeout(() => {
next() this.scroll.finishPullDown()
}, stopTime) resolve()
}, stopTime)
})
}, },
_afterPullDown(dirty) { _waitResetPullDown(dirty) {
this.resetPullDownTimer = setTimeout(() => { return new Promise(resolve => {
this.pullDownStyle = `top: -${this.pullDownHeight}px` this.resetPullDownTimer = setTimeout(() => {
this.beforePullDown = true this.pullDownStyle = `top: -${this.pullDownHeight}px`
dirty && this.refresh() this.beforePullDown = true
}, this.scroll.options.bounceTime) resolve()
}, this.scroll.options.bounceTime)
})
}, },
_getPullDownEleHeight() { _getPullDownEleHeight() {
let pulldown = this.$refs.pulldown let pulldown = this.$refs.pulldown
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册