Skip to content

Commit

Permalink
refactor(hidden-frame): 🎉 update hidden frame logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Aug 9, 2023
1 parent 92ddf5c commit 74f3c1d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,10 @@ video {
top: 3.6rem;
}

.-top-\[999999\]{
top: -999999;
}

.-z-10{
z-index: -10;
}
Expand Down
26 changes: 16 additions & 10 deletions src/components/HiddenFrame/HiddenFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ export default function HiddenFrame({ url }: IHiddenFrame): ReactElement {
const [active, setActive] = useState<boolean>(true);

useEffect(() => {
setInterval(() => {
url && setActive((prev) => !prev);
}, 30000);
const timer = setInterval(() => {
url && setActive(!active);
}, 10000);

return () => {
clearInterval(timer);
};
}, [active, url]);

return (
<Fragment>
<iframe
title="iframe"
allow="clipboard-read"
className="absolute grid-cols-1 gap-6"
src={url ? url.replace("wss://", "https://") + "health" : ""}
onLoad={() => console.log("iframe loaded")}
/>
{active && (
<iframe
title="iframe"
allow="clipboard-read"
className="absolute -top-[9999px]"
src={url ? url.replace("wss://", "https://") + "health" : ""}
onLoad={() => console.log("iframe loaded")}
/>
)}
</Fragment>
);
}

0 comments on commit 74f3c1d

Please sign in to comment.