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

SVG in HTML: Zoom doesn't go to the cursor (with fix using jQuery) #14

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

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a html document containing a SVG element (not positioned in the top 
left corner!)
2. Try to zoom using the mousewheel

What is the expected output? What do you see instead?
The zoom should go "into" the cursor, like here: 
http://www.cyberz.org/projects/SVGPan/tiger.svg Instead, when zooming in, the 
image drifts away in one direction.

What version of the product are you using? On what operating system?
SVGPan library 1.2.2; Probably all browsers are affected.

The following seems to work, but needs jQuery and changes to SVGPan.js:

Change the function getEventPoint() to:


function getEventPoint(evt) {
    var p = root.createSVGPoint();

        var errorX = $("#mydiv").offset().left-$(window).scrollLeft();
        var errorY = $("#mydiv").offset().top-$(window).scrollTop();

    p.x = evt.clientX-errorX;
    p.y = evt.clientY-errorY;

    return p;
}

Whereas "mydiv" is the id of the div, containing the svg-tag.

Original issue reported on code.google.com by [email protected] on 27 Feb 2012 at 5:43

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