Skip to content

Commit d9bad19

Browse files
committed
applied resize changes to WebGL template inside Packages
1 parent 85b6dad commit d9bad19

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

Assets/WebGLTemplates/SequenceReact/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Sequence Unity</title>
7+
<title>Sequence Unity Demo</title>
88
</head>
99
<body>
1010
<div id="root"></div>

Assets/WebGLTemplates/SequenceReact/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
left: 0;
1818
width: 100%;
1919
height: 100%;
20-
background: grey;
20+
background: #1a1a1a;
2121
/* We'll set the following Flex properties in order to center the text. */
2222
display: flex;
2323
justify-content: center;

Assets/WebGLTemplates/SequenceReact/src/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
color-scheme: light dark;
77
color: rgba(255, 255, 255, 0.87);
8-
background-color: #242424;
8+
background-color: #1a1a1a;
99

1010
font-synthesis: none;
1111
text-rendering: optimizeLegibility;

Packages/Sequence-Unity/WebGLTemplates/SequenceReact/src/App.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
.container {
1010
position: relative;
11-
/* The container determains the size. */
12-
width: 800px;
13-
height: 600px;
1411
}
1512

1613
.container > .loading-overlay {

Packages/Sequence-Unity/WebGLTemplates/SequenceReact/src/App.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ import "./App.css";
5050
}
5151
}, [messageToSend]);
5252

53-
useEffect(() => {
54-
addEventListener("GoogleSignIn", handleGoogleSignIn);
55-
return () => {
56-
removeEventListener("GoogleSignIn", handleGoogleSignIn);
57-
};
58-
}, []);
53+
useEffect(() => {
54+
addEventListener("GoogleSignIn", handleGoogleSignIn);
55+
window.addEventListener("resize", handleResize);
56+
handleResize()
57+
return () => {
58+
removeEventListener("GoogleSignIn", handleGoogleSignIn);
59+
window.removeEventListener("resize", handleResize);
60+
};
61+
}, []);
5962

6063
const [showLogin, setShowLogin] = useState(false);
6164

@@ -68,6 +71,23 @@ import "./App.css";
6871
setShowLogin(false);
6972
};
7073

74+
const handleResize = () => {
75+
const container = document.querySelector('.container') as any;
76+
77+
let w = window.innerWidth * 0.98;
78+
let h = window.innerHeight * 0.98;
79+
80+
const r = 600 / 960;
81+
if (w * r > window.innerHeight) {
82+
w = Math.min(w, Math.ceil(h / r));
83+
}
84+
85+
h = Math.floor(w * r);
86+
87+
container.style.width = w + "px";
88+
container.style.height = h + "px";
89+
}
90+
7191
return (
7292
<div className="outer-container">
7393
<div className="container">

0 commit comments

Comments
 (0)