You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a KiwiJS game is embedded in a document, and its position on the page shifts around without a window resize, then Stage.offset fails to update. This will result in inaccurate pointer input coordinates.
Unfortunately, from discussion on Stack Overflow, it seems there isn't a standard for detecting div resize events yet. There are some alternatives, but many rely on timers/RAFs and could be moderately heavy.
My intuition says there might be an optimal solution. We could use a "dirty" mark. Say we tag the offset as dirty at the start of each frame; and we cache the parameters used to create the offset. Then, when we access the offset, if it is dirty, and if the parameters have changed, we recalculate it, then mark it as clean. This will require a minimum of one extra boolean assignation per frame, a fixed cost increase, and a maximum of running the offset calculation once per frame, plus a boolean check every time offset is accessed.
It's probably worthwhile, as this will improve reliability on the web.
The alternative is to recommend that users call Stage.offset = Stage.getOffsetPoint( blah ) every time they manipulate the DOM, and that could rapidly get messy.
The text was updated successfully, but these errors were encountered:
If a KiwiJS game is embedded in a document, and its position on the page shifts around without a window resize, then
Stage.offset
fails to update. This will result in inaccurate pointer input coordinates.Unfortunately, from discussion on Stack Overflow, it seems there isn't a standard for detecting div resize events yet. There are some alternatives, but many rely on timers/RAFs and could be moderately heavy.
My intuition says there might be an optimal solution. We could use a "dirty" mark. Say we tag the offset as dirty at the start of each frame; and we cache the parameters used to create the offset. Then, when we access the offset, if it is dirty, and if the parameters have changed, we recalculate it, then mark it as clean. This will require a minimum of one extra boolean assignation per frame, a fixed cost increase, and a maximum of running the offset calculation once per frame, plus a boolean check every time offset is accessed.
It's probably worthwhile, as this will improve reliability on the web.
The alternative is to recommend that users call
Stage.offset = Stage.getOffsetPoint( blah )
every time they manipulate the DOM, and that could rapidly get messy.The text was updated successfully, but these errors were encountered: