[HTML5] Better fullscreen, canvas resizing.
Three canvas resize policies: - `None`: Godot window settings are ignored. - `Project`: Godot handles the canvas like a native app (resizing it when setting the window size). - `Adaptive`: Canvas size will always adapt to browser window size. Use `None` if you want to control the canvas size with custom JavaScript code.
This commit is contained in:
17
misc/dist/html/full-size.html
vendored
17
misc/dist/html/full-size.html
vendored
@ -161,23 +161,6 @@ $GODOT_HEAD_INCLUDE
|
||||
}
|
||||
requestAnimationFrame(animate);
|
||||
|
||||
function adjustCanvasDimensions() {
|
||||
const scale = window.devicePixelRatio || 1;
|
||||
if (lastWidth != window.innerWidth || lastHeight != window.innerHeight || lastScale != scale) {
|
||||
lastScale = scale;
|
||||
lastWidth = window.innerWidth;
|
||||
lastHeight = window.innerHeight;
|
||||
canvas.width = Math.floor(lastWidth * scale);
|
||||
canvas.height = Math.floor(lastHeight * scale);
|
||||
canvas.style.width = lastWidth + "px";
|
||||
canvas.style.height = lastHeight + "px";
|
||||
}
|
||||
}
|
||||
if (GODOT_CONFIG['canvasResizePolicy'] == 2) {
|
||||
animationCallbacks.push(adjustCanvasDimensions);
|
||||
adjustCanvasDimensions();
|
||||
}
|
||||
|
||||
function setStatusMode(mode) {
|
||||
|
||||
if (statusMode === mode || !initializing)
|
||||
|
||||
Reference in New Issue
Block a user