Giter Site home page Giter Site logo

Comments (7)

anvaka avatar anvaka commented on August 19, 2024

Could you please give an example here https://jsfiddle.net or somewhere else where I could test it?

from panzoom.

daverodal avatar daverodal commented on August 19, 2024

yes It seems to work now, i will reverify that it's broken.....

If it is I will give example, thanks again

from panzoom.

TrevorSundberg avatar TrevorSundberg commented on August 19, 2024

The example fiddle that was given actually has an invalid zoom point:
https://jsfiddle.net/uwxcmbyg/

If you resize the windows (especially shrink the javascript window to the left) then it will be very obvious (at least it is on Chrome).

from panzoom.

Schnark avatar Schnark commented on August 19, 2024

As far as I can tell, this has something to do with the viewBox attribute. I can reproduce with the following files:

HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Panzoom test</title>
<script src="panzoom.min.js"></script>
<script>
window.addEventListener('load', function () {
	panzoom(document.getElementById('container'));
});
</script>
</head>
<body>
<svg viewBox="0 0 800 500">
<g id="container"><circle cx="150" cy="150" r="40"/></g>
</svg>
</body>
</html>

Or with pure SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
	viewBox="0 0 800 500">
<defs>
<script xlink:href="panzoom.min.js"/>
<script>//<![CDATA[
window.addEventListener('load', function () {
	panzoom(document.getElementById('container'));
});
//]]></script>
</defs>
<g id="container"><circle cx="150" cy="150" r="40"/></g>
</svg>

When I open any of these files in my browser and try to zoom with the mouse cursor over the center of the circle, I'd expect the circle to stay in its place and just zoom, but it actually also moves.

When I remove the viewBox attribute, zooming works as expected in both cases.

from panzoom.

anvaka avatar anvaka commented on August 19, 2024

Yup. viewBox is causing the bug. Not sure yet how to fix it.

from panzoom.

anvaka avatar anvaka commented on August 19, 2024

This should be fixed now. Demo: http://jsbin.com/siyipif/1/edit?html,output

from panzoom.

daverodal avatar daverodal commented on August 19, 2024

thanks anvaka this is wonderful news

from panzoom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.