timmywil / panzoom

A library for panning and zooming elements using CSS transforms :mag:
https://timmywil.com/panzoom/
MIT License
2.14k stars 416 forks source link

Trying to crop visible area of panzoom - how to handle zoom/scale for x/y coords #638

Open rich06 opened 1 year ago

rich06 commented 1 year ago

Hello

Cool library - thanks for all the hard work!

I am trying to crop the visible area of a panzoom controlled image. I'm doing this by converting the image to a canvas using the panzoom pan coordinates as offsets for the crop. This works fine when no scaling/zooming occurs but when that happens the coordinates no longer match the 'visible' area.

What's the best way to achieve this? Any suggestions welcome!

Thanks in advance Rich