sprotty icon indicating copy to clipboard operation
sprotty copied to clipboard

Allow limits on zooming / panning

Open spoenemann opened this issue 7 years ago • 2 comments
trafficstars

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.

spoenemann avatar Oct 30 '18 09:10 spoenemann

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.

tunesmith avatar May 13 '22 06:05 tunesmith

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.

spoenemann avatar May 13 '22 08:05 spoenemann