Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Jul 25, 2024
1 parent 6a083b2 commit 556d563
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions app/components/artifact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ export function HTMLPreview(props: {
*/

useEffect(() => {
window.addEventListener("message", (e) => {
const handleMessage = (e) => {
const { id, height, title } = e.data;
setTitle(title);
if (id == frameId.current) {
setIframeHeight(height);
}
});
}, [iframeHeight]);
};
window.addEventListener("message", handleMessage);
return () => {
window.removeEventListener("message", handleMessage);
};
}, []);

const height = useMemo(() => {
const parentHeight = props.height || 600;
Expand Down
8 changes: 6 additions & 2 deletions app/components/ui-lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,15 @@ export function FullScreen(props: any) {
}
}, []);
useEffect(() => {
document.addEventListener("fullscreenchange", (e) => {
const handleScreenChange = (e) => {
if (e.target === ref.current) {
setFullScreen(!!document.fullscreenElement);
}
});
};
document.addEventListener("fullscreenchange", handleScreenChange);
return () => {
document.removeEventListener("fullscreenchange", handleScreenChange);
};
}, []);
return (
<div ref={ref} style={{ position: "relative" }} {...rest}>
Expand Down

0 comments on commit 556d563

Please sign in to comment.