Created
March 1, 2017 06:25
-
-
Save 2livebrew/57049e01ae0bc8e71801f681260bedcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isMouseDown = false | |
let points | |
let drawLoop = ()=>{ | |
if(isMouseDown) window.requestAnimationFrame(drawLoop) | |
draw() | |
} | |
let mouseDown = (e)=>{ | |
isMouseDown = true | |
points = [getPointerData(e)] | |
window.requestAnimationFrame(drawLoop) | |
} | |
let mouseMove = (e)=>{ | |
if(isMouseDown) points.push(getPointerData(e)) | |
} | |
let mouseUp = (e)=>{ | |
isMouseDown = false | |
} | |
let draw = ()=>{ | |
//drawing | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment