diff --git a/src/client/ui/client.js b/src/client/ui/client.js index 2a9da7eb6..fe919dc09 100644 --- a/src/client/ui/client.js +++ b/src/client/ui/client.js @@ -33,15 +33,15 @@ svgCanvas = new SvgCanvas(drawingArea); + network = realTimeConnection; + network.connect(window.location.port); + drawingArea.preventBrowserDragDefaults(); - sendPointerEventsOverNetwork(); + handleRealTimeNetwork(); handleClearScreenClick(); handleMouseDragEvents(); handleTouchDragEvents(); - network = realTimeConnection; - network.connect(window.location.port); - return svgCanvas; }; @@ -49,11 +49,35 @@ svgCanvas = null; }; - function sendPointerEventsOverNetwork() { - drawingArea.onMouseMove(function(coordinate) { + function handleRealTimeNetwork() { + documentBody.onMouseMove(function(coordinate) { + var relativeOffset = coordinate.toRelativeOffset(drawingArea); + network.sendPointerLocation(relativeOffset.x, relativeOffset.y); + }); + documentBody.onSingleTouchMove(function(coordinate) { var relativeOffset = coordinate.toRelativeOffset(drawingArea); network.sendPointerLocation(relativeOffset.x, relativeOffset.y); }); + + var allCursors = {}; + + network.onPointerLocation(function(event) { + var id = event.id; + if (allCursors[id] === undefined) allCursors[id] = createCursor(); + moveCursor(allCursors[id], event.x, event.y); + }); + + function createCursor() { + var cursor = HtmlElement.fromHtml("
