1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-07-30 20:47:46 +00:00

cube: get touch centroid instead of first touch

This commit is contained in:
RGBCube 2025-06-02 03:10:49 +03:00
parent 512663f5c6
commit 977f8858b0
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -189,10 +189,18 @@
document.addEventListener("mousemove", handleMove);
document.addEventListener("touchmove", (event) => {
const delta = event.changedTouches[0];
const { x, y } = Array
.from(event.touches)
.reduce(
(acc, touch) => ({
x: acc.x + touch.clientX,
y: acc.y + touch.clientY,
}),
{ x: 0, y: 0 }
);
event.clientX = delta.clientX;
event.clientY = delta.clientY;
event.clientX = x / event.touches.length;
event.clientY = y / event.touches.length;
handleMove(event);
});