Skip to content

Commit b3d7f79

Browse files
committed
Make the zoom in keyboard shortcut center the selected node
1 parent f2edb75 commit b3d7f79

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/ts/core/features/spatial-mode/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const config: Feature = {
4949
...SpatialSettings.all,
5050
spatialShortcut('Ctrl+=', 'Zoom in', viewport => viewport.zoomBy(5 / 4)),
5151
spatialShortcut('Ctrl+-', 'Zoom out', viewport => viewport.zoomBy(4 / 5)),
52-
spatialShortcut('Ctrl+0', 'Zoom in completely', viewport => viewport.zoomBy(10)),
52+
spatialShortcut('Ctrl+0', 'Zoom in completely', viewport => viewport.zoomIntoSelection()),
5353
spatialShortcut('Ctrl+9', 'Zoom out completely', viewport => viewport.zoomOutCompletely()),
5454
spatialShortcut('Ctrl+ArrowLeft', 'Pan left', viewport => {
5555
viewport.panBy(-SpatialSettings.panSpeed(), 0)

src/ts/core/features/spatial-mode/spatial-viewport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export class SpatialViewport {
8181
this.cy.panBy({x: -x, y: -y})
8282
}
8383

84+
zoomIntoSelection() {
85+
this.zoomBy(10)
86+
this.cy.center(this.selectedNodes())
87+
}
88+
8489
selectedNodes(): NodeCollection {
8590
return this.cy.nodes(':selected')
8691
}

0 commit comments

Comments
 (0)