Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ff pheno fix #543

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions frontend/src/components/ThePhenogrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/util/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.getCTM()) return;
let point = svg.createSVGPoint();
point.x = x;
point.y = y;
Expand Down