anvaka / panzoom

Universal pan and zoom library (DOM, SVG, Custom)

Home Page:https://anvaka.github.io/panzoom/demo/attach-via-script.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mismatch between getTransform - zoomAbs

pautasso opened this issue · comments

I am trying to restore the state of a panzoom instance

// memento the current transformation state
state = instance.getTransform()

// recover the state
instance.zoomAbs(state.x, state.y, state.scale)

the instance doesn't go back to the same state.

While looking at the code I might as well comment.
getTransform might return Object.assign({},transform), but it returns transform.
However, if it does return the copy (no lower levels ... simple object), then the handlers will not be able to manipulate transforms by changing field values explicitly.

Internally, transform is a global value always containing the current transform state.

Perhaps there needs to be another method.