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
Move the cursor out of the viewport (still holding click)
Release click outside the viewport
Move the cursor back to the viewport
Click Undo
Unhandled errors occur while moving the cursor
The order in this case: pointerDown (canvas)
-> pointerMove (inside to outside canvas)
-> pointerMove (back to canvas)
-> onClick (undo button)
-> pointerMove (canvas)
-> pointerDown (canvas)
-> pointerUp (canvas)
line.mp4pencil.mp4rect.mp4
Possible Solutions
We should combine multiple techniques together.
Technique 1
Excalidraw calls onPointerUp handler when the mouse is moved out of canvas in the middle of drawing. How? maybe they use onPointerOut, onPointerLeave ??
Technique 2
Excalidraw: they set pointer-events: none to all floating buttons, e.g. undo button, while the user starts dragging an element in the canvas.
Technique 3
In every event handler, first check for an expected state before proceed any actions. For unexpected/uninterested state, do nothing. (i.e. Finite state machine)
pointerDown (canvas): expected none state, proceed changing to drawing state
-> pointerMove (inside to outside canvas): expected drawing state, proceed logic
-> release a pointer outside canvas
-> pointerMove (back to canvas): expected drawing state, proceed logic
-> pointerDown (canvas): unexpected drawing state, do nothing
-> pointerMove (canvas): expected drawing state, proceed logic
-> pointerUp (canvas): expected drawing state, proceed changing to none state
Other than previous state name, also beware of data that comes from previous state. Don't assume any previous data. Instead, always check if data is valid, e.g. check if id of element we are editing is valid. (i.e. Make sure every event handler is stateless and independent from any previous event handlers)
The text was updated successfully, but these errors were encountered:
pobch
changed the title
Bug: No guarantee order that pointerUp will be triggered after pointerDown
No guarantee that events order will be exactly: pointerDown -> pointerMove -> pointerUpApr 10, 2022
pobch
changed the title
No guarantee that events order will be exactly: pointerDown -> pointerMove -> pointerUp
Bug: No guarantee for event order will be exactly: pointerDown -> pointerMove -> pointerUpMay 4, 2022
pobch
changed the title
Bug: No guarantee for event order will be exactly: pointerDown -> pointerMove -> pointerUp
No guarantee for event order will be exactly: pointerDown -> pointerMove -> pointerUpMay 19, 2022
Example cases:
<canvas/>
The order in this case:
pointerDown
(canvas)->
pointerMove
(inside to outside canvas)->
pointerMove
(back to canvas)->
onClick
(undo button)->
pointerMove
(canvas)->
pointerDown
(canvas)->
pointerUp
(canvas)line.mp4
pencil.mp4
rect.mp4
Possible Solutions
We should combine multiple techniques together.
Technique 1
onPointerUp
handler when the mouse is moved out of canvas in the middle of drawing. How? maybe they useonPointerOut
,onPointerLeave
??Technique 2
pointer-events: none
to all floating buttons, e.g. undo button, while the user starts dragging an element in the canvas.Technique 3
none
state, proceed changing todrawing
state-> pointerMove (inside to outside canvas): expected
drawing
state, proceed logic-> release a pointer outside canvas
-> pointerMove (back to canvas): expected
drawing
state, proceed logic-> pointerDown (canvas): unexpected
drawing
state, do nothing-> pointerMove (canvas): expected
drawing
state, proceed logic-> pointerUp (canvas): expected
drawing
state, proceed changing tonone
stateid
of element we are editing is valid. (i.e. Make sure every event handler is stateless and independent from any previous event handlers)The text was updated successfully, but these errors were encountered: