sprotty
sprotty copied to clipboard
Allow limits on zooming / panning
From theia-ide/sprotty#220:
One can get lost by zooming extremely far in or out or by panning far away. It should be possible to configure limits on how far one can zoom and pan.
Just curious if anyone has examples on how to custom implement this in a local project if the library itself does not have support? Would it just be a matter of attaching event listeners to the div that contains the svg and doing the math? I noticed that the sprotty examples (like circlegraph) can basically zoom in and out to infinity.
A long time ago I implemented something in jquery that limits zoom and pan, example here, but I don't know if it could be adapted to sprotty.
A possible solution would be to bind a different implementation of SetViewportCommand (viewport.ts), for example with a subclass that limits the viewport in its constructor.
rebind(SetViewportCommand).to(CustomSetViewportCommand);
To solve this in a generic way, we could add respective optional properties to ViewerOptions and inject them in SetViewportCommand.