Skip to content

Commit

Permalink
window_tab\kanban 添加配置
Browse files Browse the repository at this point in the history
  • Loading branch information
obgnail committed Sep 9, 2023
1 parent 7f009b4 commit a9624af
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
14 changes: 8 additions & 6 deletions plugin/custom/plugins/kanban.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
6 changes: 4 additions & 2 deletions plugin/global/settings/custom_plugin.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -43,8 +45,8 @@ TEMPLATE = """```kanban
- 当描述为空时隐藏描述框
## In-Progress
- 当任务数量太多,出现滚动条时(可以将鼠标置于看板下,使用【鼠标滚轮】切换任务)
- 当看板数量太多,出现滚动条时(可以将鼠标置于看板下,使用【ctrl+鼠标滚轮】切换看板)
- 当任务数量太多,出现滚动条时(可以将鼠标置于看板下,使用【鼠标滚轮】滚动任务)
- 当看板数量太多,出现滚动条时(可以将鼠标置于看板下,使用【ctrl+鼠标滚轮】滚动看板)
## Completed
- NOTE(语法是开发者定义的,没有通用性,只建议用于【每日任务】临时使用)
Expand Down
2 changes: 2 additions & 0 deletions plugin/global/settings/settings.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 11 additions & 10 deletions plugin/window_tab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down

0 comments on commit a9624af

Please sign in to comment.