[READ-ONLY] Mirror of https://github.com/probablykasper/canvas-experiments. Just me learning to use HTML canvas canvas-experiments.kasper.space
canvas html5-canvas website
0

Configure Feed

Select the types of activity you want to include in your feed.

8. Testing drawing with touch

KH (Jun 24, 2017, 11:58 PM +0200) 23746b56 2fb9cec6

+18 -3
+17 -3
8/main.js
··· 15 15 // var oldmx = mx; 16 16 // var oldmy = my; 17 17 var mx, my, oldmx, oldmy; 18 + 18 19 window.addEventListener("mousedown", function() { 19 20 mousedown = true; 20 21 }); 22 + window.addEventListener("touchstart", function() { 23 + mousedown = true; 24 + }); 25 + 21 26 window.addEventListener("mouseup", function() { 22 27 mousedown = false; 23 28 }); 29 + window.addEventListener("touchend", function() { 30 + mousedown = false; 31 + }); 32 + 24 33 window.addEventListener("mousemove", function(e) { 25 34 oldmx = mx; 26 35 oldmy = my; 27 36 mx = window.event.clientX; 28 37 my = window.event.clientY; 29 - if (mousedown) { 30 - draw(); 31 - } 38 + if (mousedown) draw(); 39 + }); 40 + window.addEventListener("touchmove", function(e) { 41 + oldmx = mx; 42 + oldmy = my; 43 + mx = window.event.clientX; 44 + my = window.event.clientY; 45 + if (mousedown) draw(); 32 46 }); 33 47 34 48 function draw() {
+1
index.php
··· 10 10 </head> 11 11 12 12 <body> 13 + <a href="8">8. Drawing</a> 13 14 <a href="7">7. Three fancy loading animations</a> 14 15 <a href="5">5. and now they bounce off of each other</a> 15 16 <a href="4">4. many boucning circles with random colors, radiuses and window resize support</a>