PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.7
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.7
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / scripts / utils / iframe.ts

iframe.ts in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.0.7, at scripts/utils/iframe.ts

41 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useEffect, useState } from 'react';
2 import Raven from '../lib/Raven';
3
4 const IFRAME_DISPLAY_TIMEOUT = 5000;
5
6 export function useIframeNotRendered(app: string) {
7 const [iframeNotRendered, setIframeNotRendered] = useState(false);
8 useEffect(() => {
9 const timer = setTimeout(() => {
10 const iframe = document.getElementById(app);
11 if (!iframe) {
12 Raven.captureException(new Error(`Leadin Iframe blocked`), {
13 fingerprint: ['IFRAME_SETUP_ERROR'],
14 });
15 setIframeNotRendered(true);
16 }
17 }, IFRAME_DISPLAY_TIMEOUT);
18
19 return () => {
20 if (timer) {
21 clearTimeout(timer);
22 }
23 };
24 }, []);
25
26 return iframeNotRendered;
27 }
28
29 export const resizeWindow = () => {
30 const adminMenuWrap = document.getElementById('adminmenuwrap');
31 const sideMenuHeight = adminMenuWrap ? adminMenuWrap.offsetHeight : 0;
32 const adminBar = document.getElementById('wpadminbar');
33 const adminBarHeight = (adminBar && adminBar.offsetHeight) || 0;
34 const offset = 4;
35 if (window.innerHeight < sideMenuHeight) {
36 return sideMenuHeight - offset;
37 } else {
38 return window.innerHeight - adminBarHeight - offset;
39 }
40 };
41