@mui/x-internal-gestures
Version:
The core engine of GestureEvents, a modern and robust multi-pointer gesture detection library for JavaScript.
28 lines (26 loc) • 709 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.calculateRotationAngle = calculateRotationAngle;
var _getAngle = require("./getAngle");
/**
* Calculate the rotation angle between pointers
* This uses the angle between the first two pointers relative to the centroid
*/
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 (0, _getAngle.getAngle)(p1, p2);
}