-
Notifications
You must be signed in to change notification settings - Fork 224
Open
Description
Been using OGL for a bit to create shaders. Nice library, thank you!
Problem:
The Renderer logic currently adds width
and height
on canvas
in addition to an inline style
tag:

Because of these inline styles, it isn't possible to make the canvas
element responsive based on its own clientWidth
. The canvas will be set up with default styles but will not reflow on resize.
canvas {
width: 100%;
}
// Will not work! The inline styles prevent `clientWidth` from updating.
// On first load, the canvas will be appropriately sized at 100%, but
// the element won't reflow or change sizes along with the rest of the DOM.
function updateCanvasSize() {
const { clientWidth, clientHeight } = canvas;
renderer.setSize(clientWidth, clientHeight);
}
render() {
// ...
updateCanvasSize();
}
Fix:
Do not set inline style
on canvas
. Allow users to update the canvas size during the render loop as illustrated in this example.
monolithMktg
Metadata
Metadata
Assignees
Labels
No labels