Skip to content

Commit 07f048b

Browse files
committed
refactor: Use early return
1 parent 124d85c commit 07f048b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/components/RecycleScroller.vue

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,10 @@ export default {
291291
let startIndex, endIndex
292292
let totalSize
293293
294-
if (!count) {
295-
startIndex = endIndex = totalSize = 0
296-
} else if (this.$_prerender) {
297-
startIndex = 0
298-
endIndex = this.prerender
299-
totalSize = null
300-
} else {
301-
const scroll = this.getScroll()
294+
let scroll
295+
296+
if (count && !this.$_prerender) {
297+
scroll = this.getScroll()
302298
303299
// Skip update if use hasn't scrolled enough
304300
if (checkPositionDiff) {
@@ -310,6 +306,15 @@ export default {
310306
}
311307
}
312308
}
309+
}
310+
311+
if (!count) {
312+
startIndex = endIndex = totalSize = 0
313+
} else if (this.$_prerender) {
314+
startIndex = 0
315+
endIndex = this.prerender
316+
totalSize = null
317+
} else {
313318
this.$_lastUpdateScrollPosition = scroll.start
314319
315320
const buffer = this.buffer

0 commit comments

Comments
 (0)