Tempo: Fix graph dragging (#79508)

* Fix graph dragging

* Add comment
This commit is contained in:
Joey 2023-12-15 10:43:35 +00:00 committed by GitHub
parent cacae6a43b
commit 8a6ea4bfad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -6377,6 +6377,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"]
],
"public/app/plugins/panel/nodeGraph/usePanning.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/nodeGraph/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]

View File

@ -183,12 +183,14 @@ function inBounds(value: number, min: number | undefined, max: number | undefine
return Math.min(Math.max(value, min ?? -Infinity), max ?? Infinity);
}
// The issue here is that TouchEvent is undefined while using instanceof in Firefox and Safari
// which will throw an exception but if it's (event as TouchEvent).changedTouches it will be undefined
// and the if check will fail so it will go to the else but will not throw an exception
function getEventXY(event: Event): { x: number; y: number } {
if (event instanceof TouchEvent) {
if ((event as TouchEvent).changedTouches && event instanceof TouchEvent) {
return { x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY };
} else if (event instanceof MouseEvent) {
return { x: event.clientX, y: event.clientY };
} else {
return { x: 0, y: 0 };
}
return { x: 0, y: 0 };
}