Skip to content

Commit

Permalink
fix: snapPoint edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommezz committed May 10, 2020
1 parent 8115bb6 commit 4caa8d5
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,22 @@ export class ScrollBottomSheet<T extends any> extends Component<Props<T>> {

const didHandleGestureBegin = eq(handleGestureState, GestureState.ACTIVE);

const scrollY = cond(
didHandleGestureBegin,
[set(dragWithHandle, 1), 0],
cond(eq(dragWithHandle, 1), 0, lastStartScrollY)
);
const scrollY = [
cond(didHandleGestureBegin, [set(dragWithHandle, 1), 0]),
cond(
and(
eq(dragWithHandle, 1),
greaterThan(snapPoints[0], sub(lastSnap, abs(dragY))),
not(eq(lastSnap, snapPoints[0]))
),
[
set(lastSnap, snapPoints[0]),
set(dragWithHandle, 0),
lastStartScrollY,
],
cond(eq(dragWithHandle, 1), 0, lastStartScrollY)
),
];

const isAnimationInterrupted = and(
or(
Expand Down Expand Up @@ -355,6 +366,7 @@ export class ScrollBottomSheet<T extends any> extends Component<Props<T>> {
set(prevTranslateYOffset, animationPosition),
set(animationFinished, 1),
stopClock(animationClock),
set(lastSnap, animationPosition),
animationPosition,
]),
cond(
Expand Down

0 comments on commit 4caa8d5

Please sign in to comment.