Skip to content

Commit

Permalink
fix: apply scroll velocity to outer container
Browse files Browse the repository at this point in the history
  • Loading branch information
bbohlender committed Mar 13, 2024
1 parent 77ccda6 commit 434fed7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/uikit/src/scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,20 @@ export function ScrollHandler({
enableRubberBand: boolean,
) => {
const [wasScrolledX, wasScrolledY] = event == null ? [false, false] : getWasScrolled(event.nativeEvent)
if (wasScrolledX && wasScrolledY) {
return
if (wasScrolledX) {
deltaX = 0
}
if (wasScrolledY) {
deltaY = 0
}
const [x, y] = scrollPosition.value
const [maxX, maxY] = node.maxScrollPosition.value
let [newX, newY] = scrollPosition.value
const [ancestorScrollableX, ancestorScrollableY] = node.anyAncestorScrollable?.value ?? [false, false]
if (!wasScrolledX) {
newX = computeScroll(x, maxX, deltaX, enableRubberBand && !ancestorScrollableX)
}
if (!wasScrolledY) {
newY = computeScroll(y, maxY, deltaY, enableRubberBand && !ancestorScrollableY)
}

newX = computeScroll(x, maxX, deltaX, enableRubberBand && !ancestorScrollableX)
newY = computeScroll(y, maxY, deltaY, enableRubberBand && !ancestorScrollableY)

if (deltaTime != null && deltaTime > 0) {
scrollVelocity.set(deltaX, deltaY).divideScalar(deltaTime)
}
Expand Down

0 comments on commit 434fed7

Please sign in to comment.