BetterTyped/react-zoom-pan-pinch

memoized instance context properties

Closed this issue · 1 comments

Is your feature request related to a problem? Please describe.
Hi! This feature is requested because in my app, I need a controlled zoom. In this case, I need to have a local state synchronized with the library state. That's why I use useTransformEffect in order to have fresh scale and set it in my local state. The problem with that, is that when I move the flow (scale is not changing, but positionX and positionY), it fires the useTransformEffect so the content renders again and again. Due to this, the performance is affected.

Describe the solution you'd like
I have thought about solutions for this and I think that If I had the current zoom in other way, I would not need a local state for that.
The only thing is that we would need the useTransformContext exporting the properties memoized I thing. Or maybe we could have different contexts.
This way, we could use the scale property from the context. But if the position X of the context changes, It would not fire the render of the component using only the scale.
I do not know if it makes sense to you :)

Thanks!

Closed at the moment because I am missing something. I will explore my code more.