# Zoom to mouse position

**URL:** <https://forum.inductiveautomation.com/t/zoom-to-mouse-position/93379>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 18, 2024, 7:35am UTC](https://forum.inductiveautomation.com/t/zoom-to-mouse-position/93379 "2024-07-18T07:35:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederic\_Avet](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@Frederic\_Avet](https://forum.inductiveautomation.com/u/Frederic_Avet)\
**Post date:** [July 18, 2024, 7:35am UTC](https://forum.inductiveautomation.com/t/zoom-to-mouse-position/93379/1 "2024-07-18T07:35:39Z")

</div>

I have succeeded in panning and zooming a view containing an svg but now it just zooms to the center of the view.  
I have been trying to figure out what the best way to calculate the required panning while zooming to focus on the mouse.  
Would anybody have any ideas or experience with this?

---

<div class="post-metadata">

**Author:** ![simeonw](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@simeonw](https://forum.inductiveautomation.com/u/simeonw)\
**Post date:** [July 18, 2024, 6:20pm UTC](https://forum.inductiveautomation.com/t/zoom-to-mouse-position/93379/2 "2024-07-18T18:20:22Z")

</div>

This post on stackoverflow shows you how to achieve this using a transformation matrix on a group object within the SVG itself:

> <https://stackoverflow.com/questions/28121561/zooming-to-cursor-position-in-svg-documents>

Check out JSFiddle link in solution comment:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/7/479980299e407857f6db7a5f8ec45904e9d933c6.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/9/89e42ceca03fe47cc248e98597d18d419308497e.png)

If you are able to listen for changes to the zoom level already, then implementing the JS solution above in jython might be possible.
