Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
18 lines
569 B
TypeScript
18 lines
569 B
TypeScript
/**
|
|
* Maps layout vs visual viewport into a keyboard-sized bottom inset (px).
|
|
* Returns 0 for small deltas (browser UI / zoom) so desktop and Android
|
|
* layout-resizing keyboards stay no-ops.
|
|
*/
|
|
export const computeKeyboardInset = (
|
|
innerHeight: number,
|
|
visualViewportHeight: number,
|
|
visualViewportOffsetTop: number,
|
|
minKeyboardPx = 80
|
|
): number => {
|
|
const inset = Math.max(0, Math.round(innerHeight - visualViewportHeight - visualViewportOffsetTop))
|
|
|
|
return inset >= minKeyboardPx ? inset : 0
|
|
}
|
|
|
|
export const KEYBOARD_INSET_CSS_VAR = '--keyboard-inset'
|