dy / pan-zoom

Pan / zoom for any element
MIT License
88 stars 15 forks source link

x/y values between touch events #22

Closed soulfresh closed 4 years ago

soulfresh commented 4 years ago

What does this PR do?

Resolves an issue where x/y values are inaccurate if the dimensions of the target element have changed between change events. This occurs if the user of this library updates the scale of the target element (or its content) in response to dz changes. The fix is achieved by tracking touch events against the window and then translating those screen coordinates into coordinates relative to the target element.

I'm not sure if this will pose issues for any consumers of this library who may be depending on the current functionality.

Fixes #11

soulfresh commented 4 years ago

For anyone interested, I've created an API compatible package that resolves this issue and issues #11 and #18:

https://www.npmjs.com/package/@thesoulfresh/pan-zoom

dy commented 4 years ago

@soulfresh that's pretty cool. Sorry for holding that on. I can't work on that for the meantime, would you like to take handle of that?

soulfresh commented 4 years ago

Were you hoping for PRs on the issues I mentioned or were you thinking of merging my package into yours? My package has one change that may pose problems for current users; I removed the requestAnimationFrame usage so that library users have control over that. Otherwise, it's API compatible.

dy commented 4 years ago

Ok, I see, it is more elaborate than I initially thought. I've added your package to the readme.