Skip to content

Commit c035b24

Browse files
committed
fix(recycle-view): #16 修复forceUpdate时计算slot-before,slot-after无效
1 parent c0b95c5 commit c035b24

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/recycle-view.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -550,20 +550,26 @@ Component({
550550
// 重新渲染事件发生
551551
let beforeReady = false
552552
let afterReady = false
553-
this.createSelectorQuery().select('.slot-before').boundingClientRect((rect) => {
554-
beforeSlotHeight = rect.height
555-
beforeReady = true
556-
if (afterReady) {
557-
if (newCb) { newCb() }
558-
}
559-
}).exec()
560-
this.createSelectorQuery().select('.slot-after').boundingClientRect((rect) => {
561-
afterSlotHeight = rect.height
562-
afterReady = true
563-
if (beforeReady) {
564-
if (newCb) { newCb() }
565-
}
566-
}).exec()
553+
// fix:#16 确保获取slot节点实际高度
554+
this.setData({
555+
hasBeforeSlotHeight: false,
556+
hasAfterSlotHeight: false,
557+
}, () => {
558+
this.createSelectorQuery().select('.slot-before').boundingClientRect((rect) => {
559+
beforeSlotHeight = rect.height
560+
beforeReady = true
561+
if (afterReady) {
562+
if (newCb) { newCb() }
563+
}
564+
}).exec()
565+
this.createSelectorQuery().select('.slot-after').boundingClientRect((rect) => {
566+
afterSlotHeight = rect.height
567+
afterReady = true
568+
if (beforeReady) {
569+
if (newCb) { newCb() }
570+
}
571+
}).exec()
572+
})
567573
},
568574
_setInnerBeforeAndAfterHeight(obj) {
569575
if (typeof obj.beforeHeight !== 'undefined') {

0 commit comments

Comments
 (0)