natashawylie / iviewer

image viewer plugin for jquery
233 stars 97 forks source link

How to zoom specific part of the image ? #86

Open laxmi-lal-menaria opened 9 years ago

laxmi-lal-menaria commented 9 years ago

I would like to zoom specific part of the image, I have tried the moveTo/setCoords but I think its not working.

Please let me know how can I do this..

i.e If I have a image size 800*600, would like to zoom the top left area on button click, on next button zoom the right area, on next button zoom middle ...and so on...

can3p commented 9 years ago

There is no ready method for that, but you can implement it yourself. Suppose you have width, height and coordinates of desired area. widget stores dimensions of the container in the options object. So, from that values you can get the zoom value, that you need to set in order to fit this area in viewport of container. You can set this value to via set_zoom method. After that it's possible to center image in a proper place via moveTo method.

Current api is not that easy to use in all cases, so sometimes it's not trivial how to implement this or that.