Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: where initialY differed by -34px #148

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/SheetContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { motion } from 'framer-motion';
import { SheetContainerProps } from './types';
import { useSheetContext } from './context';
import { useEventCallbacks } from './hooks';
import { MAX_HEIGHT } from './constants';
import { MAX_HEIGHT, SAFE_AREA_TOP_OFFSET } from './constants';
import { mergeRefs } from './utils';
import styles from './styles';

Expand All @@ -24,7 +24,9 @@ const SheetContainer = React.forwardRef<any, SheetContainerProps>(
} = useSheetContext();

const { handleAnimationComplete } = useEventCallbacks(isOpen, callbacks);
const initialY = snapPoints ? snapPoints[0] - snapPoints[initialSnap] : 0;
const initialY = snapPoints
? snapPoints[0] - snapPoints[initialSnap] - SAFE_AREA_TOP_OFFSET
: 0;
const maxSnapHeight = snapPoints ? snapPoints[0] : null;

const height =
Expand Down
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const MAX_HEIGHT = 'calc(100% - env(safe-area-inset-top) - 34px)';
export const SAFE_AREA_TOP_OFFSET = 34;

export const MAX_HEIGHT = `calc(100% - env(safe-area-inset-top) - ${SAFE_AREA_TOP_OFFSET}px)`;

export const IS_SSR = typeof window === 'undefined';

Expand Down