Reputation: 324
I wanted to execute some additional code when the panzoom 'reset' option is selected by the end-user, but there is no setOnReset
API. I was looking for a recommended way of executing custom code in addition to the standard resetZoom()
and resetPan()
.
[Edited] However, I think my problem is deeper which is why I have modified the title. The additional code was to reset to a zoom level of say 0.98 (rather than 1) so that a small margin is left around the outermost shapes -- otherwise they're right up against the SVG border if fit:true
which looks awful.
I had tried simply overriding the standard reset()
as follows:
pzInst.reset = function() {
pzInst.resetPan(); pzInst.resetZoom(); pzInst.zoomBy(0.95);
}
But it does not work: the SVG no longer centers, and seems to go to the top-left. I have tried 3.5.2 and 3.6.1 but the effect is the same.
Am I doing something wrong? Is there a better way to achieve what I want?
Upvotes: 1
Views: 76