robashton / camera

Just a camera implementation over the top of HTML5 canvas
http://codeofrob.com
96 stars 19 forks source link

How to make camera zoom move to initial pointer location while zooming? #8

Open kapv89 opened 1 year ago

kapv89 commented 1 year ago

Hi, so I am using code from this in a project with an infinite canvas with multiple objects. The behaviour I'd like is that when zooming starts and the mouse pointer is over a certain object, that object moves to the center of the viewport as zoom progresses. Any idea how to achieve this?

JuxtNorth commented 1 year ago

You'd have to first detect whether the mouse pointer is above an object, then move the camera to that object's position using the moveTo function and then zoom in/out

kapv89 commented 8 months ago

See erdtool.com (currently on pause) .. uses code in this lib