Skip to content

Commit 35c0ad2

Browse files
committed
fix: Items are not checked when scroll start is above the fold
1 parent 07f048b commit 35c0ad2

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/components/RecycleScroller.vue

+16-11
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export default {
298298
299299
// Skip update if use hasn't scrolled enough
300300
if (checkPositionDiff) {
301-
let positionDiff = scroll.start - this.$_lastUpdateScrollPosition
301+
let positionDiff = scroll.originalStart - this.$_lastUpdateScrollPosition
302302
if (positionDiff < 0) positionDiff = -positionDiff
303303
if ((itemSize === null && positionDiff < minItemSize) || positionDiff < itemSize) {
304304
return {
@@ -315,7 +315,7 @@ export default {
315315
endIndex = this.prerender
316316
totalSize = null
317317
} else {
318-
this.$_lastUpdateScrollPosition = scroll.start
318+
this.$_lastUpdateScrollPosition = scroll.originalStart
319319
320320
const buffer = this.buffer
321321
scroll.start -= buffer
@@ -507,37 +507,42 @@ export default {
507507
getScroll () {
508508
const { $el: el, direction } = this
509509
const isVertical = direction === 'vertical'
510-
let scrollState
511510
512511
if (this.pageMode) {
513512
const bounds = el.getBoundingClientRect()
514513
const boundsSize = isVertical ? bounds.height : bounds.width
515-
let start = -(isVertical ? bounds.top : bounds.left)
516-
let size = isVertical ? window.innerHeight : window.innerWidth
514+
const originalStart = -(isVertical ? bounds.top : bounds.left)
515+
const originalSize = isVertical ? window.innerHeight : window.innerWidth
516+
let start = originalStart
517+
let size = originalSize
518+
517519
if (start < 0) {
518520
size += start
519521
start = 0
520522
}
521523
if (start + size > boundsSize) {
522524
size = boundsSize - start
523525
}
524-
scrollState = {
526+
return {
527+
originalStart,
525528
start,
526529
end: start + size,
527530
}
528-
} else if (isVertical) {
529-
scrollState = {
531+
}
532+
533+
if (isVertical) {
534+
return {
535+
originalStart: el.scrollTop,
530536
start: el.scrollTop,
531537
end: el.scrollTop + el.clientHeight,
532538
}
533539
} else {
534-
scrollState = {
540+
return {
541+
originalStart: el.scrollLeft,
535542
start: el.scrollLeft,
536543
end: el.scrollLeft + el.clientWidth,
537544
}
538545
}
539-
540-
return scrollState
541546
},
542547
543548
applyPageMode () {

0 commit comments

Comments
 (0)