Skip to content

Commit

Permalink
Don't modify snapPoints prop value and update y initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
Temzasse committed Oct 27, 2024
1 parent 1dc8c88 commit 7018321
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Sheet = forwardRef<any, SheetProps>(
children,
disableScrollLocking = false,
isOpen,
snapPoints,
snapPoints: snapPointsProp,
rootId,
mountPoint,
style,
Expand Down Expand Up @@ -82,7 +82,7 @@ const Sheet = forwardRef<any, SheetProps>(
// NOTE: the inital value for `y` doesn't matter since it is overwritten by
// the value driven by the `AnimatePresence` component when the sheet is opened
// and after that it is driven by the gestures and/or snapping
const y = useMotionValue(0);
const y = useMotionValue(windowHeight);

// +2 for tolerance in case the animated value is slightly off
const zIndex = useTransform(y, (value) =>
Expand Down Expand Up @@ -110,6 +110,8 @@ const Sheet = forwardRef<any, SheetProps>(
};
});

let snapPoints: number[] | undefined = snapPointsProp;

if (snapPoints) {
// Convert negative / percentage snap points to absolute values
snapPoints = snapPoints.map((point) => {
Expand Down

0 comments on commit 7018321

Please sign in to comment.