Listing 10-116. User Input Capture Methods
function getDrawPosition(e) { var canvasRect = document.getElementById('scratchCanvas').getBoundingClientRect(); var xPos = e.clientX - canvasRect.left; var yPos = e.clientY - canvasRect.top; return new Position(xPos, yPos);}function mouseMove(e) { canvasBrushMove(getDrawPosition(e));}function mouseDown(e) { canvasBrushDown(getDrawPosition(e));}function mouseUp(e) { canvasBrushUp(getDrawPosition(e));}function msTouchStart(e) { e.preventDefault(); if (firstTouch == null && e.buttons == 1) { firstTouch = e.pointerId; canvasBrushDown(new Position(e.clientX, e.clientY)); }}function msTouchMove(e) { e.preventDefault(); if (firstTouch == e.pointerId) { ...
Get Pro ASP.NET SignalR: Real-Time Communication in .NET with SignalR 2.1 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.