Fixes updating BlazorGameWindow.ClientBounds & mouse/touch positions#2593
Open
squarebananas wants to merge 2 commits into
Open
Fixes updating BlazorGameWindow.ClientBounds & mouse/touch positions#2593squarebananas wants to merge 2 commits into
squarebananas wants to merge 2 commits into
Conversation
squarebananas
marked this pull request as ready for review
March 19, 2026 14:39
squarebananas
force-pushed
the
ClientBoundsPosition
branch
from
July 24, 2026 14:54
aea9ac3 to
556e6c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently Kni.BlazorGL only works correctly when the canvas is a full viewport element located at the origin position (using an Iframe also works as internally it acts like the whole viewport). If the
canvasHolderis reposition/resized to appear elsewhere then the canvas doesn't update correctly. The mouse/touch input positions are also wrong.The existing
JsWindowOnResizeevent cannot be used for partial viewport / non origin element locations either, as the full window size values will not be applicable in these cases.To resolve these issues, this PR ensures the
BlazorGameWindow.ClientBoundsmatch the actualcanvasHolderposition and size. This is then used to updatetheCanvassize, callUpdateBackBufferSize, and adjust mouse/touch input positions accordingly.Also the templates currently set both the
canvasHolderandtheCanvasto use the css position offixed. However this meanstheCanvasdoesn't actually get placed inside thecanvasHolderand instead acts like it is floating separately from it. By changingtheCanvasto use a css position ofabsolute, it instead is placed inside thecanvasHolderand is repositioned accordingly.The associated required Wasm changes ("Adds DOMRect and Element.GetBoundingClientRect") are located here:
nkast/Wasm#18