@mui/x-internal-gestures
Version:
The core engine of GestureEvents, a modern and robust multi-pointer gesture detection library for JavaScript.
23 lines (21 loc) • 568 B
JavaScript
import { getAngle } from "./getAngle.js";
/**
* Calculate the rotation angle between pointers
* This uses the angle between the first two pointers relative to the centroid
*/
export function calculateRotationAngle(pointers) {
if (pointers.length < 2) {
return 0;
}
// For rotation, we need exactly 2 pointers
// Use first two since they're most likely the primary pointers
const p1 = {
x: pointers[0].clientX,
y: pointers[0].clientY
};
const p2 = {
x: pointers[1].clientX,
y: pointers[1].clientY
};
return getAngle(p1, p2);
}