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
We should not use resize event of window because of the following scenarios:
In Android:
A user chooses the text tool
The user click at the very bottom of the page
A Soft keyboard opens
It triggers resize event
resize event handler modifies the canvas size to fit the smaller screen(remaining screen above the soft keyboard)
The user won't see a text input in the screen since the text input is position: absolute and the screen has no scroll now(after it was shrunk). The text input is actually placed off-screen now.
In iOS:
A user chooses the text tool
The user click at the very bottom of the page
A Soft keyboard opens
It does NOT trigger resize event
One way of hack if we really want to use resize event is trying to separate normal resize event from soft-keyboard triggered resize event. Soft-keyboard should change the height only, and the width is not changed. However, the url bar also behave like this?? We have to add the check for how many px the height was changed??
Can we find a way to detect whether the soft keyboard(i.e. virtual keyboard) is opening?? Use this logic to bail out resize event triggered by the soft keyboard.
Explore window.screen.availHeight
Explore window.visualViewport
Use ResizeObserver with <html> or <body> element instead?? Let's try it. But, I think it won't work.
After resize the canvas, we need to force re-draw the canvas. To do it, create a new function forceReLoadCurrentSnapshot() inside useHistory().
constnewHistory=[...history]newHistory[currentSnapshotIndex]=[...history[currentSnapshotIndex]]setHistory(newHistory)// Steps:// 1. The currentSnapshot array is re-created// 2. Dep array of `useEffect()` is triggered// 3. Draw function(inside `useEffect()`) is triggered
The text was updated successfully, but these errors were encountered:
resize
event ofwindow
because of the following scenarios:resize
eventresize
event handler modifies the canvas size to fit the smaller screen(remaining screen above the soft keyboard)position: absolute
and the screen has no scroll now(after it was shrunk). The text input is actually placed off-screen now.resize
eventresize
event is trying to separate normalresize
event from soft-keyboard triggeredresize
event. Soft-keyboard should change theheight
only, and thewidth
is not changed. However, the url bar also behave like this?? We have to add the check for how many px theheight
was changed??resize
event triggered by the soft keyboard.window.screen.availHeight
window.visualViewport
ResizeObserver
with<html>
or<body>
element instead?? Let's try it. But, I think it won't work.forceReLoadCurrentSnapshot()
insideuseHistory()
.The text was updated successfully, but these errors were encountered: