Skip to content

Commit 7cd077b

Browse files
New: Add zoom in and out functions (#100)
1 parent d02a980 commit 7cd077b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/views/orb-view.ts

+20
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,26 @@ export class OrbView<N extends INodeBase, E extends IEdgeBase> implements IOrbVi
564564
}
565565
};
566566

567+
zoomIn = (onRendered?: () => void) => {
568+
select(this._renderer.canvas)
569+
.transition()
570+
.duration(this._settings.zoomFitTransitionMs)
571+
.ease(easeLinear)
572+
.call(this._d3Zoom.scaleBy, 1.2)
573+
.call(() => {
574+
this.render(onRendered);
575+
});
576+
};
577+
578+
zoomOut = (onRendered?: () => void) => {
579+
select(this._renderer.canvas)
580+
.transition()
581+
.duration(this._settings.zoomFitTransitionMs)
582+
.ease(easeLinear)
583+
.call(this._d3Zoom.scaleBy, 0.8)
584+
.call(() => this.render(onRendered));
585+
};
586+
567587
private _update: IObserver = (data?: IObserverDataPayload): void => {
568588
if (data && 'x' in data && 'y' in data && 'id' in data) {
569589
this._simulator.patchData({

0 commit comments

Comments
 (0)