Skip to content

Commit

Permalink
fix: Items are not checked when scroll start is above the fold
Browse files Browse the repository at this point in the history
  • Loading branch information
dam1r89 committed Apr 19, 2020
1 parent 07f048b commit 35c0ad2
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/components/RecycleScroller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export default {
// Skip update if use hasn't scrolled enough
if (checkPositionDiff) {
let positionDiff = scroll.start - this.$_lastUpdateScrollPosition
let positionDiff = scroll.originalStart - this.$_lastUpdateScrollPosition
if (positionDiff < 0) positionDiff = -positionDiff
if ((itemSize === null && positionDiff < minItemSize) || positionDiff < itemSize) {
return {
Expand All @@ -315,7 +315,7 @@ export default {
endIndex = this.prerender
totalSize = null
} else {
this.$_lastUpdateScrollPosition = scroll.start
this.$_lastUpdateScrollPosition = scroll.originalStart
const buffer = this.buffer
scroll.start -= buffer
Expand Down Expand Up @@ -507,37 +507,42 @@ export default {
getScroll () {
const { $el: el, direction } = this
const isVertical = direction === 'vertical'
let scrollState
if (this.pageMode) {
const bounds = el.getBoundingClientRect()
const boundsSize = isVertical ? bounds.height : bounds.width
let start = -(isVertical ? bounds.top : bounds.left)
let size = isVertical ? window.innerHeight : window.innerWidth
const originalStart = -(isVertical ? bounds.top : bounds.left)
const originalSize = isVertical ? window.innerHeight : window.innerWidth
let start = originalStart
let size = originalSize
if (start < 0) {
size += start
start = 0
}
if (start + size > boundsSize) {
size = boundsSize - start
}
scrollState = {
return {
originalStart,
start,
end: start + size,
}
} else if (isVertical) {
scrollState = {
}
if (isVertical) {
return {
originalStart: el.scrollTop,
start: el.scrollTop,
end: el.scrollTop + el.clientHeight,
}
} else {
scrollState = {
return {
originalStart: el.scrollLeft,
start: el.scrollLeft,
end: el.scrollLeft + el.clientWidth,
}
}
return scrollState
},
applyPageMode () {
Expand Down

0 comments on commit 35c0ad2

Please sign in to comment.