Skip to content

Commit

Permalink
fix: drawer resize code
Browse files Browse the repository at this point in the history
  • Loading branch information
JinleeJeong committed Mar 31, 2024
1 parent ea4e464 commit cf0f237
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/(input)/ticker/_components/ticker-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface TickerDrawerProps {
handleConfirmClick: () => void;
}

const DRAWER_OFFSET = 96;
export const TickerDrawer = React.memo(
({
drawerType,
Expand Down Expand Up @@ -68,15 +69,14 @@ export const TickerDrawer = React.memo(
if (drawerRef.current === null) return;

const visualViewportHeight = window.visualViewport?.height ?? 0;
// const keyboardHeight = window.innerHeight - visualViewportHeight;
const keyboardHeight = window.innerHeight - visualViewportHeight;

// Difference between window height and height excluding the keyboard
const diffFromInitial = window.innerHeight - visualViewportHeight;

// const drawerHeight = drawerRef.current?.getBoundingClientRect().height || 0;
const drawerHeight = drawerRef.current?.getBoundingClientRect().height || 0;

drawerRef.current.style.height = `${visualViewportHeight - (window.innerHeight - 100)}px`;
drawerRef.current.style.bottom = `${Math.max(diffFromInitial, 0)}px`;
drawerRef.current.style.height = `${visualViewportHeight - DRAWER_OFFSET}px`;
}

window.visualViewport?.addEventListener("resize", onVisualViewportChange);
Expand Down

0 comments on commit cf0f237

Please sign in to comment.