Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/views/orb-map-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ export class OrbMapView<N extends INodeBase, E extends IEdgeBase> implements IOr
onRendered?.();
}

zoomIn(onRendered?: () => void) {
this._leaflet.zoomIn();
onRendered?.();
}

recenter(onRendered?: () => void) {
const view = this._graph.getBoundingBox();
const topRightCoordinate = this._leaflet.layerPointToLatLng([view.x, view.y]);
Expand All @@ -206,6 +211,11 @@ export class OrbMapView<N extends INodeBase, E extends IEdgeBase> implements IOr
onRendered?.();
}

zoomOut(onRendered?: () => void) {
this._leaflet.zoomOut();
onRendered?.();
}

destroy() {
this._renderer.removeAllListeners();
this._leaflet.off();
Expand Down Expand Up @@ -240,6 +250,7 @@ export class OrbMapView<N extends INodeBase, E extends IEdgeBase> implements IOr
private _initLeaflet() {
const leaflet = L.map(this._map, {
doubleClickZoom: false,
zoomControl: false,
}).setView([0, 0], this._settings.map.zoomLevel);

leaflet.on('zoomstart', () => {
Expand Down
22 changes: 22 additions & 0 deletions src/views/orb-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ export class OrbView<N extends INodeBase, E extends IEdgeBase> implements IOrbVi
onRendered?.();
}

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

recenter(onRendered?: () => void) {
const fitZoomTransform = this._renderer.getFitZoomTransform(this._graph);

Expand All @@ -308,6 +319,17 @@ export class OrbView<N extends INodeBase, E extends IEdgeBase> implements IOrbVi
.duration(this._settings.zoomFitTransitionMs)
.ease(easeLinear)
.call(this._d3Zoom.transform, fitZoomTransform)
.call(() => {
this.render(onRendered);
});
}

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