Current Path : /storage/v11800/leadideascloud/public_html/wp-content/plugins/leadin/scripts/utils/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/leadideascloud/public_html/wp-content/plugins/leadin/scripts/utils/iframe.ts |
import { useEffect, useState } from 'react';
const IFRAME_DISPLAY_TIMEOUT = 5000;
export function useIframeNotRendered(app: string) {
const [iframeNotRendered, setIframeNotRendered] = useState(false);
useEffect(() => {
const timer = setTimeout(() => {
const iframe = document.getElementById(app);
if (!iframe) {
setIframeNotRendered(true);
}
}, IFRAME_DISPLAY_TIMEOUT);
return () => {
if (timer) {
clearTimeout(timer);
}
};
}, []);
return iframeNotRendered;
}
export const resizeWindow = () => {
const adminMenuWrap = document.getElementById('adminmenuwrap');
const sideMenuHeight = adminMenuWrap ? adminMenuWrap.offsetHeight : 0;
const adminBar = document.getElementById('wpadminbar');
const adminBarHeight = (adminBar && adminBar.offsetHeight) || 0;
const offset = 4;
if (window.innerHeight < sideMenuHeight) {
return sideMenuHeight - offset;
} else {
return window.innerHeight - adminBarHeight - offset;
}
};