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:
parent
512663f5c6
commit
977f8858b0
1 changed files with 11 additions and 3 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue