Skip to content

getScreenCTM / Zoom bug with svgs that are not positioned at the left top of the document #148

@felixwahner

Description

@felixwahner

I had a problem with zooming to the mouse position when an svg isn't rendered at the top left corner of the browser but somewhere else in the document.
(See also #132, which contains an example of the current behavior)

I traced it down to the transformToScreen method, where getScreenCTM is used. getScreenCTM returns the offset of the svg to the top and left corner of the document and from there on calculates all positions using this offset.
But the "zero point" of the svg is still at 0/0 - the offset isn't necessary and shouldn't be used at all.
When replacing the value of the following lines with 0, everything works as expected:

var parentOffsetX = parentCTM.e;

var parentOffsetY = parentCTM.f;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions