Hi, I read some similar questions here, this is a bit different.

I need to zoom to a specific point, e.g. when clicking on a class I would like the zoom to be centered on the center of that class. More in general, to any point.

I guess something like "zoomTo(scale, point)" which either change the translation or moves the scrollbars.. I don't know.

Any suggestion on the computations this method should perform?

Thanks, -s

asked 14 Apr '12, 06:51

fusio's gravatar image

accept rate: 11%

Sort of solved:

  1. take the point (screen coordinate) before scaling
  2. scale
  3. take the point (screen coordinate) after scaling
  4. compute delta of points
  5. set scroll to: oldScroll+(delta*scale)

Not sure if this is the best way to do it, but it seems to act ok.


answered 16 Apr '12, 11:51

fusio's gravatar image

accept rate: 11%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 14 Apr '12, 06:51

Seen: 2,540 times

Last updated: 16 Apr '12, 11:51