Skip to content

Commit

Permalink
New: Add zoom in and out functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexIchenskiy committed Mar 27, 2024
1 parent d02a980 commit efa5961
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/views/orb-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,26 @@ export class OrbView<N extends INodeBase, E extends IEdgeBase> implements IOrbVi
}
};

zoomIn = (onRendered?: () => void) => {
select(this._renderer.canvas)
.transition()
.duration(this._settings.zoomFitTransitionMs)
.ease(easeLinear)
.call(this._d3Zoom.scaleBy, 1.2)
.call(() => {
this.render(onRendered);
});
};

zoomOut = (onRendered?: () => void) => {
select(this._renderer.canvas)
.transition()
.duration(this._settings.zoomFitTransitionMs)
.ease(easeLinear)
.call(this._d3Zoom.scaleBy, 0.8)
.call(() => this.render(onRendered));
};

private _update: IObserver = (data?: IObserverDataPayload): void => {
if (data && 'x' in data && 'y' in data && 'id' in data) {
this._simulator.patchData({
Expand Down

0 comments on commit efa5961

Please sign in to comment.