mnogueron / react-easy-panzoom

Wrapper to enable pan and zoom features for any React component
MIT License
79 stars 17 forks source link

Fix scaleMultiplier to be multiplicatively symmetrical #51

Open juniper-wright opened 4 years ago

juniper-wright commented 4 years ago

The issue here is that when you zoom out, you reduce the scale by a factor of 0.065, but when you zoom in, you increase the scale by the same additive factor, which is not multiplicatively symmetrical -- in order to undo multiplication by 0.935, you need to multiply by 1.0695, not by 1.065.

You can see this erroneous behavior by zooming out one tick, then in one tick, then out one tick, so on and so forth -- it slowly continues to zoom out because the zoom in is slightly too little.