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

Focal point zooming running like the origin is top left when the panzoom element is large than the parent #44

Closed
timmywil opened this issue Nov 14, 2013 · 5 comments
Labels

Comments

@timmywil
Copy link
Owner

http://codepen.io/adrianosmond/pen/KjJCH

From comment

@adrianosmond
Copy link

Would having a panzoom element that's smaller than the parent also cause issues with the pan method? I've added a pan to 0,0 button to the codepen and it takes you to different places at different zoom levels.

@timmywil
Copy link
Owner Author

@adrianosmond That sounds like expected behavior. Panning simply sets the translation x and y values. You would see different parts of the panzoom element at different zoom levels.

@pensionera
Copy link

Hi,
After some test I find how you can fix this.
On line round 640 has
var clientX = focal.clientX - container.width / 2;
var clientY = focal.clientY - container.height / 2;
after change container.width and container.height with the panzoom element original width and height focal point work fine.
Something like this:
var clientX = focal.clientX - options.originWidth / 2;
var clientY = focal.clientY - options.originHeight / 2;
where originWidth and originHeight I added to options for first size of panzoom element.

@timmywil
Copy link
Owner Author

@pensionera A good suggestion, but I think we can continue automating this calculation. Patch incoming.

timmywil added a commit that referenced this issue Nov 22, 2013
* master: (33 commits)
  Use grunt-bowercopy for all bower resources and track necessary resources in git.
  Update version to 1.8.5
  Fixes gh-53. Use a custom matrix equality function rather than jQuery trickery.
  Update README.md
  Update to version 1.8.4
  Fixes gh-52. Fix tests in IE9. When resetting the transition property, it's value becomes null rather than empty string.
  Fix SVG test for IE10. When setting the transform to 'none', it removed the attribute
  Update to version 1.8.3
  Close gh-51. Account for top and left margins when calculating inverted containment.
  Add travis badge to README
  Woops spaces
  Add travis.yml
  Release 1.8.2
  Fixes gh-44. Calculate focal-point zoom origin adjustment with the panzoom element's dimensions.
  Add question to FAQ: links within panzoom elements.
  Pass through all original properties from the closing click or touch event to the panzoomend event. Fixes gh-41.
  Expose resetDimensions method to call whenever the dimensions of the element or its parent change. Fixes gh-42.
  Update file sizes
  Release 1.7.0: Support CommonJS syntax
  Add repository field to package.json
  ...

Conflicts:
	README.md
	bower.json
	demo/index.html
	dist/jquery.panzoom.js
	dist/jquery.panzoom.min.js
	package.json
	panzoom.jquery.json
	panzoom.js
@RedBraceWeb
Copy link

@timmywil
I am using the contain:invert option and running into a similar problem. I tried translating the x,y coordinates based on the scale of the image but had no success. Can you look at this sample page and tell me the best method for setting the focal point? The goal is to fire the events and pan zoom to the specific coordinates. http://redbrace.com/campusmap/map.html

@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants