From 7cd077ba0cc6d145d0708d3b3a542deb0034c472 Mon Sep 17 00:00:00 2001 From: Oleksandr Ichenskyi <55350107+AlexIchenskiy@users.noreply.github.com> Date: Thu, 28 Mar 2024 07:15:35 +0100 Subject: [PATCH] New: Add zoom in and out functions (#100) --- src/views/orb-view.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/views/orb-view.ts b/src/views/orb-view.ts index 427cc29..3b5711a 100644 --- a/src/views/orb-view.ts +++ b/src/views/orb-view.ts @@ -564,6 +564,26 @@ export class OrbView 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({