File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed
Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -71,13 +71,13 @@ export function useCollaborativeCursors({
7171 } , [ ydoc , roomName ] ) ;
7272
7373 const updateCursorPosition = useCallback (
74- ( x : number , y : number ) => {
74+ ( x : number | null , y : number | null ) => {
7575 if ( ! provider . current ?. awareness ) return ;
7676
77- const cursor = flowInstance ?. screenToFlowPosition ( {
78- x,
79- y ,
80- } ) ;
77+ const cursor =
78+ x !== null && y !== null
79+ ? flowInstance ?. screenToFlowPosition ( { x , y } )
80+ : null ;
8181
8282 provider . current . awareness . setLocalState ( {
8383 cursor,
@@ -103,14 +103,8 @@ export function useCollaborativeCursors({
103103 ) ;
104104
105105 const handleMouseLeave = useCallback ( ( ) => {
106- if ( ! provider . current ?. awareness ) return ;
107-
108- provider . current . awareness . setLocalState ( {
109- cursor : null ,
110- color : userColor . current ,
111- clientId : provider . current . awareness . clientID ,
112- } ) ;
113- } , [ ] ) ;
106+ updateCursorPosition ( null , null ) ;
107+ } , [ updateCursorPosition ] ) ;
114108
115109 return {
116110 cursors,
You can’t perform that action at this time.
0 commit comments