Skip to content

Commit

Permalink
Fixed scroll offset for entropy collection canvas on touchscreens.
Browse files Browse the repository at this point in the history
  • Loading branch information
GlitchedPolygons committed Dec 15, 2023
1 parent 067917d commit 745f70f
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions GlitchedPolygons.GlitchEd25519.BlazorWebApp/Pages/Keygen.razor
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,24 @@
isMouseDown = true;
[x, y] =
[
event.changedTouches ? event.changedTouches[0].clientX : event.offsetX,
event.changedTouches ? event.changedTouches[0].clientY : event.offsetY
];
if (event.changedTouches)
{
const boundingRect = paintCanvas.getBoundingClientRect();
[x, y] =
[
event.changedTouches[0].clientX - boundingRect.left,
event.changedTouches[0].clientY - boundingRect.top
];
}
else
{
[x, y] =
[
event.offsetX,
event.offsetY
];
}
}
const drawLine = event =>
Expand All @@ -162,8 +175,15 @@
if (isMouseDown)
{
const newX = event.changedTouches ? event.changedTouches[0].clientX : event.offsetX;
const newY = event.changedTouches ? event.changedTouches[0].clientY : event.offsetY;
const boundingRect = paintCanvas.getBoundingClientRect();
const newX = event.changedTouches
? event.changedTouches[0].clientX - boundingRect.left
: event.offsetX;
const newY = event.changedTouches
? event.changedTouches[0].clientY - boundingRect.top
: event.offsetY;
context.beginPath();
context.moveTo(x, y);
Expand Down

0 comments on commit 745f70f

Please sign in to comment.