Skip to content

Commit

Permalink
Use page margin as the origin
Browse files Browse the repository at this point in the history
  • Loading branch information
yinanazhou committed May 10, 2024
1 parent 3a01da8 commit 10dfc10
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/Coordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export interface BBox {
export function getSVGRelCoords (clientX: number, clientY: number): Point {
const pt = new DOMPoint(clientX, clientY);
const svg = document.querySelector<SVGSVGElement>('.active-page > .definition-scale');
const system = svg.querySelector<SVGGElement>('.system');
const pageMargin = svg.querySelector<SVGGElement>('.page-margin');

const { x, y } = pt.matrixTransform(system.getScreenCTM().inverse());
const { x, y } = pt.matrixTransform(pageMargin.getScreenCTM().inverse());
return { x, y };

// If there is some issue with coordinates, this may fix the issue:
Expand Down

0 comments on commit 10dfc10

Please sign in to comment.