make grid-scroll-focused center the focused column

This commit is contained in:
Peter Fajdiga
2023-06-17 10:32:24 +02:00
parent b614fd4481
commit e1263dd544
3 changed files with 8 additions and 2 deletions

View File

@@ -216,7 +216,7 @@ function initActions(world: World) {
}
const column = focusedWindow.column;
const grid = column.grid;
grid.scrollToColumn(column);
grid.scrollCenterColumn(column);
grid.arrange();
},

View File

@@ -121,7 +121,7 @@ const keyBindings: KeyBinding[] = [
},
{
"name": "grid-scroll-focused",
"description": "Scroll to focused window",
"description": "Center focused window",
"defaultKeySequence": "Meta+Alt+Return",
"action": "gridScrollFocused",
},

View File

@@ -153,6 +153,12 @@ class Grid {
}
}
scrollCenterColumn(column: Column) {
const windowCenter = column.gridX + column.width / 2 + this.world.config.gapsInnerHorizontal - this.scrollX; // in screen space
const screenCenter = this.tilingArea.x + this.tilingArea.width / 2;
this.adjustScroll(Math.round(windowCenter - screenCenter), false);
}
autoAdjustScroll() {
const focusedWindow = this.world.getFocusedWindow();
if (focusedWindow === null) {