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

Problems with setCTM when the viewBox transformation is large #30

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create an svg with top level like:

<svg width=400 height=400 viewBox="0 0 10000 6000">
<g id="g" transform="scale(1 1) rotate(0) translate( 5 6000 )">...</g>
</svg>

2. Attempt a scaling transformation via mouseWheel


What is the expected output? What do you see instead?

The view should scale around the mouse cursor point.  Instead, the scaled view 
jumps to a new point.


What version of the product are you using? On what operating system? Top of 
tree.  I'm actually using jquery-svgpan, but the critical routines are the same.


Please provide any additional information below.

The problem arises because the setCTM routine does not take into account the 
viewBox transformation.  I was able to fix this set of problems by substituting 
the following implementation of setCTM:

setCTM = function (element, matrix) {
    element.transform.baseVal.consolidate();

    // The goal is to set element.transform to some matrix T='mat2' 
    // such that the new CTM is equal to the given input matrix.  The 
    // expression we need for 'mat2' is 
    //   T=(newCTM)*(inverse(oldCTM))*oldT .
    var mat2 = element.transform.baseVal.getItem(0).matrix.multiply(element.getCTM().inverse()).multiply(matrix);
                    element.transform.baseVal.replaceItem(element.transform.baseVal.createSVGTransformFromMatrix(mat2), 0);
},

Original issue reported on code.google.com by [email protected] on 31 Jan 2014 at 10:52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant