From 2a272649c4ee8379ec52329ee99938cdb5e662ff Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Fri, 19 Jan 2024 14:09:48 -0500 Subject: [PATCH 1/2] fix firefox phenogrid scroll bug --- frontend/src/components/ThePhenogrid.vue | 13 ++++++++++--- frontend/src/util/dom.ts | 7 +++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/ThePhenogrid.vue b/frontend/src/components/ThePhenogrid.vue index a1128f959..1adab50d4 100644 --- a/frontend/src/components/ThePhenogrid.vue +++ b/frontend/src/components/ThePhenogrid.vue @@ -495,17 +495,24 @@ const scrollInfo = useScroll(scroll); const scrollCoords = ref({ x: 0, y: 0, w: 0, h: 0 }); function updateScroll() { if (!svg.value || !scroll.value) return; - const { x, y } = screenToSvgCoords( + const position = screenToSvgCoords( svg.value, scrollInfo.x.value, scrollInfo.y.value, ); - const { x: w, y: h } = screenToSvgCoords( + if (!position) return; + const dimensions = screenToSvgCoords( svg.value, scroll.value.clientWidth, scroll.value.clientHeight, ); - scrollCoords.value = { x: x + marginLeft, y: y + marginTop, w, h }; + if (!dimensions) return; + scrollCoords.value = { + x: position.x + marginLeft, + y: position.y + marginTop, + w: dimensions.x, + h: dimensions.y, + }; } watch(() => scrollInfo, updateScroll, { deep: true }); useResizeObserver(scroll, updateScroll); diff --git a/frontend/src/util/dom.ts b/frontend/src/util/dom.ts index 43b2340bd..18a989406 100644 --- a/frontend/src/util/dom.ts +++ b/frontend/src/util/dom.ts @@ -38,8 +38,11 @@ export const firstInView = (elements: HTMLElement[]): number => { /** convert screen coordinates to svg coordinates */ export const screenToSvgCoords = (svg: SVGSVGElement, x: number, y: number) => { - /** https://bugzilla.mozilla.org/show_bug.cgi?id=543965 */ - if (!svg || !svg.getCTM()) return new DOMPoint(0, 0); + /** + * https://bugzilla.mozilla.org/show_bug.cgi?id=543965 no viable workarounds + * found + */ + if (!svg || !svg.getCTM()) return; let point = svg.createSVGPoint(); point.x = x; point.y = y; From 01bb3e80342b8724b2ad966025493c08a1af43cf Mon Sep 17 00:00:00 2001 From: Vincent Rubinetti Date: Fri, 19 Jan 2024 14:10:14 -0500 Subject: [PATCH 2/2] remove vestigial check --- frontend/src/util/dom.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/util/dom.ts b/frontend/src/util/dom.ts index 18a989406..271ea007c 100644 --- a/frontend/src/util/dom.ts +++ b/frontend/src/util/dom.ts @@ -42,7 +42,7 @@ export const screenToSvgCoords = (svg: SVGSVGElement, x: number, y: number) => { * https://bugzilla.mozilla.org/show_bug.cgi?id=543965 no viable workarounds * found */ - if (!svg || !svg.getCTM()) return; + if (!svg.getCTM()) return; let point = svg.createSVGPoint(); point.x = x; point.y = y;