UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

12 lines (11 loc) 408 B
export function getBestFitPosition() { if (typeof window === 'undefined') return { left: 0, top: 0 }; if (typeof window.screen === 'undefined') return { left: 0, top: 0 }; if (window) { const { width, height } = window.screen; const { innerWidth, innerHeight } = window; const left = width / 2 - innerWidth / 2; const top = height / 2 - innerHeight / 2; return { left, top }; } }