From a9624af102f5ce2eeea5d6e7ee35d4b376e1a651 Mon Sep 17 00:00:00 2001 From: obgnail Date: Sat, 9 Sep 2023 17:37:37 +0800 Subject: [PATCH] =?UTF-8?q?window=5Ftab\kanban=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/custom/plugins/kanban.js | 14 +++++++------ .../settings/custom_plugin.default.toml | 6 ++++-- plugin/global/settings/settings.default.toml | 2 ++ plugin/window_tab/index.js | 21 ++++++++++--------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/plugin/custom/plugins/kanban.js b/plugin/custom/plugins/kanban.js index 58d93461..378f4631 100644 --- a/plugin/custom/plugins/kanban.js +++ b/plugin/custom/plugins/kanban.js @@ -124,12 +124,14 @@ class kanbanPlugin extends BaseCustomPlugin { } ) - const that = this; - $("#write").on("wheel", ".plugin-kanban-content", function (ev) { - if (that.utils.metaKeyPressed(ev.originalEvent)) { - this.scrollLeft += ev.originalEvent.deltaY; - } - }) + if (this.config.CTRL_WHEEL_TO_SCROLL) { + const that = this; + $("#write").on("wheel", ".plugin-kanban-content", function (ev) { + if (that.utils.metaKeyPressed(ev.originalEvent)) { + this.scrollLeft += ev.originalEvent.deltaY; + } + }) + } } callback = anchorNode => { diff --git a/plugin/global/settings/custom_plugin.default.toml b/plugin/global/settings/custom_plugin.default.toml index 981c3bad..f9dd2e68 100644 --- a/plugin/global/settings/custom_plugin.default.toml +++ b/plugin/global/settings/custom_plugin.default.toml @@ -15,6 +15,8 @@ enable = true HIDE_DESC_WHEN_EMPTY = true # 看板最大高度(若<0,则全部显示) KANBAN_MAX_HEIGHT = 700 +# 当鼠标位于看板时,ctrl+wheel滚动看板 +CTRL_WHEEL_TO_SCROLL = true # 看板的颜色 # 如果你新增了颜色,请保持 KANBAN_COLOR 和 TASK_COLOR 数量一致,否则颜色会乱套,就不好看了 KANBAN_COLOR = [ @@ -43,8 +45,8 @@ TEMPLATE = """```kanban - 当描述为空时隐藏描述框 ## In-Progress -- 当任务数量太多,出现滚动条时(可以将鼠标置于看板下,使用【鼠标滚轮】切换任务) -- 当看板数量太多,出现滚动条时(可以将鼠标置于看板下,使用【ctrl+鼠标滚轮】切换看板) +- 当任务数量太多,出现滚动条时(可以将鼠标置于看板下,使用【鼠标滚轮】滚动任务) +- 当看板数量太多,出现滚动条时(可以将鼠标置于看板下,使用【ctrl+鼠标滚轮】滚动看板) ## Completed - NOTE(语法是开发者定义的,没有通用性,只建议用于【每日任务】临时使用) diff --git a/plugin/global/settings/settings.default.toml b/plugin/global/settings/settings.default.toml index f094cc94..c5bf3561 100644 --- a/plugin/global/settings/settings.default.toml +++ b/plugin/global/settings/settings.default.toml @@ -32,6 +32,8 @@ CLOSE_HOTKEY = ["ctrl+w"] SWITCH_NEXT_TAB_HOTKEY = ["ctrl+PageDown", "ctrl+Tab"] # 切换上一个标签页的快捷键 SWITCH_PREVIOUS_TAB_HOTKEY = ["ctrl+PageUp", "ctrl+shift+Tab"] +# 当鼠标位于标签页时,ctrl+wheel切换标签页 +CTRL_WHEEL_TO_SCROLL = true # 内部使用 LOOP_DETECT_INTERVAL = 35 diff --git a/plugin/window_tab/index.js b/plugin/window_tab/index.js index 52cff8cb..f95d6296 100644 --- a/plugin/window_tab/index.js +++ b/plugin/window_tab/index.js @@ -253,17 +253,18 @@ class windowTabBarPlugin extends global._basePlugin { } }) + if (this.config.CTRL_WHEEL_TO_SCROLL) { + this.entities.tabBar.addEventListener("wheel", ev => { + const target = ev.target.closest("#plugin-window-tab .tab-bar"); + if (!target) return; - this.entities.tabBar.addEventListener("wheel", ev => { - const target = ev.target.closest("#plugin-window-tab .tab-bar"); - if (!target) return; - - if (this.utils.metaKeyPressed(ev)) { - (ev.deltaY < 0) ? this.previousTab() : this.nextTab(); - } else { - target.scrollLeft += ev.deltaY; - } - }) + if (this.utils.metaKeyPressed(ev)) { + (ev.deltaY < 0) ? this.previousTab() : this.nextTab(); + } else { + target.scrollLeft += ev.deltaY; + } + }) + } this.entities.content.addEventListener("scroll", () => { if (this.tabUtil.tabs[this.tabUtil.activeIdx]) {