Refactored files.

This commit is contained in:
Jay
2025-08-01 20:24:19 -04:00
parent fa641c186c
commit c6118c8b0d
5 changed files with 125 additions and 140 deletions
+24
View File
@@ -1,3 +1,27 @@
export function minmax(number: number, min: number, max: number) {
return Math.min(max, Math.max(min, number));
}
export function isTouchEvent(event: Event): event is TouchEvent {
return "touches" in event;
}
export function isLeftMouseButton(buttonsValue: number) {
return buttonsValue === 1;
}
export function extractEventCoordinates(event: MouseEvent | TouchEvent): {
clientX: number;
clientY: number;
} {
if (isTouchEvent(event)) {
return {
clientX: event.touches[0].clientX,
clientY: event.touches[0].clientY,
};
}
return {
clientX: event.clientX,
clientY: event.clientY,
};
}