From 067917d19bfd5c7b3862058a5f37237bfaeb4e4d Mon Sep 17 00:00:00 2001 From: Glitched Polygons Date: Fri, 15 Dec 2023 03:51:43 +0100 Subject: [PATCH] Improved entropy collection canvas for touchscreens. --- .../Pages/Keygen.razor | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/GlitchedPolygons.GlitchEd25519.BlazorWebApp/Pages/Keygen.razor b/GlitchedPolygons.GlitchEd25519.BlazorWebApp/Pages/Keygen.razor index a174483..a757552 100644 --- a/GlitchedPolygons.GlitchEd25519.BlazorWebApp/Pages/Keygen.razor +++ b/GlitchedPolygons.GlitchEd25519.BlazorWebApp/Pages/Keygen.razor @@ -139,22 +139,31 @@ configContext(); const stopDrawing = () => - { + { isMouseDown = false; } const startDrawing = event => { - isMouseDown = true; - [x, y] = [event.offsetX, event.offsetY]; + event.preventDefault(); + + isMouseDown = true; + + [x, y] = + [ + event.changedTouches ? event.changedTouches[0].clientX : event.offsetX, + event.changedTouches ? event.changedTouches[0].clientY : event.offsetY + ]; } const drawLine = event => { + event.preventDefault(); + if (isMouseDown) { - const newX = event.offsetX; - const newY = event.offsetY; + const newX = event.changedTouches ? event.changedTouches[0].clientX : event.offsetX; + const newY = event.changedTouches ? event.changedTouches[0].clientY : event.offsetY; context.beginPath(); context.moveTo(x, y);