@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 735 B
JavaScript
import{useEffect as o,useState as d}from"react";export const useWindowSize=()=>{const[i,n]=d(()=>window!==window.top?{width:document.documentElement.clientWidth||window.innerWidth,height:document.documentElement.clientHeight||window.innerHeight}:{width:window.innerWidth,height:window.innerHeight});return o(()=>{const e=()=>{const t=window!==window.top;n(t?{width:document.documentElement.clientWidth||window.innerWidth,height:document.documentElement.clientHeight||window.innerHeight}:{width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",e),window.addEventListener("orientationchange",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("orientationchange",e)}},[]),i};