fix(components): fix virtual list scroll&wheel handler (#11472)

fix xEndEdge&yEndEdge logic when wheel event emits

fix hasReachedEdge logic when  offsetX

offsetY is zero

closed #11463, #11155

Co-authored-by: 迦叶(仝航) <jiaye@xiaohongshu.com>
This commit is contained in:
Rapliangle
2023-02-08 23:20:46 +08:00
committed by GitHub
parent 3d747a0e56
commit 2793c8477f
2 changed files with 8 additions and 4 deletions

View File

@ -326,11 +326,15 @@ const createGrid = ({
{
atXStartEdge: computed(() => states.value.scrollLeft <= 0),
atXEndEdge: computed(
() => states.value.scrollLeft >= estimatedTotalWidth.value
() =>
states.value.scrollLeft >=
estimatedTotalWidth.value - unref(parsedWidth)
),
atYStartEdge: computed(() => states.value.scrollTop <= 0),
atYEndEdge: computed(
() => states.value.scrollTop >= estimatedTotalHeight.value
() =>
states.value.scrollTop >=
estimatedTotalHeight.value - unref(parsedHeight)
),
},
(x: number, y: number) => {

View File

@ -21,9 +21,9 @@ export const useGridWheel = (
const hasReachedEdge = (x: number, y: number) => {
const xEdgeReached =
(x < 0 && atXStartEdge.value) || (x > 0 && atXEndEdge.value)
(x <= 0 && atXStartEdge.value) || (x >= 0 && atXEndEdge.value)
const yEdgeReached =
(y < 0 && atYStartEdge.value) || (y > 0 && atYEndEdge.value)
(y <= 0 && atYStartEdge.value) || (y >= 0 && atYEndEdge.value)
return xEdgeReached && yEdgeReached
}