From 3ba66f1c8914a17d46597f49b3a59b09827cf9dd Mon Sep 17 00:00:00 2001 From: Peter Fajdiga Date: Sat, 20 Apr 2024 15:30:05 +0200 Subject: [PATCH] World: extract function `createScroller` --- src/world/World.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/world/World.ts b/src/world/World.ts index 44a949f..33f4f28 100644 --- a/src/world/World.ts +++ b/src/world/World.ts @@ -45,10 +45,7 @@ class World { marginBottom: config.gapsOuterBottom, marginLeft: config.gapsOuterLeft, marginRight: config.gapsOuterRight, - scroller: config.scrollingLazy ? new LazyScroller() : - config.scrollingCentered ? new CenteredScroller() : - config.scrollingGrouped ? new GroupedScroller() : - console.assert(false), + scroller: World.createScroller(config), clamper: config.scrollingLazy ? new EdgeClamper() : new CenterClamper(), }, layoutConfig, @@ -60,6 +57,19 @@ class World { this.update(); } + private static createScroller(config: Config) { + if (config.scrollingLazy) { + return new LazyScroller(); + } else if (config.scrollingCentered) { + return new CenteredScroller(); + } else if (config.scrollingGrouped) { + return new GroupedScroller(); + } else { + log("No scrolling mode selected, using default"); + return new LazyScroller(); + } + } + private addExistingClients() { const kwinClients = Workspace.windows; for (let i = 0; i < kwinClients.length; i++) {