Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite recursion on resize #413

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/views/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ interface GLCanvasProps {
}
export class GLCanvas extends StatelessComponent<GLCanvasProps> {
private canvas: HTMLCanvasElement | null = null
private inResize = false

private ref = (canvas: Element | null) => {
if (canvas instanceof HTMLCanvasElement) {
Expand All @@ -90,6 +91,7 @@ export class GLCanvas extends StatelessComponent<GLCanvasProps> {
private maybeResize = () => {
if (!this.container) return
if (!this.props.canvasContext) return
if (this.inResize) return

let {width, height} = this.container.getBoundingClientRect()

Expand All @@ -98,12 +100,14 @@ export class GLCanvas extends StatelessComponent<GLCanvasProps> {
const widthInPixels = width * window.devicePixelRatio
const heightInPixels = height * window.devicePixelRatio

this.inResize = true
this.props.canvasContext.gl.resize(
widthInPixels,
heightInPixels,
widthInAppUnits,
heightInAppUnits,
)
this.inResize = false
}

onWindowResize = () => {
Expand Down