Skip to content

Commit

Permalink
make scroll snapping optional
Browse files Browse the repository at this point in the history
fixes #7
  • Loading branch information
phil294 committed May 14, 2023
1 parent d030697 commit 1d020d5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ Please consider opening an issue or PR if you think a certain action warrants a
```jsonc
// VSCode settings.json
{
"git-log--graph.disable-scroll-snapping": {
"description": "If active, the mouse wheel event on the scroller will not be caught and instead behave normally. This comes at the expense of the dotted connection lines at the top being offset wrongly more often.",
"type": "boolean",
"default": false
},
"git-log--graph.branch-width": {
"description": "The width of the individual branch lines, including both line and right spacing. The default 'auto' chooses between 10 and 2 depending on the size of the repository.",
"type": [
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@
"string"
],
"default": "auto"
},
"git-log--graph.disable-scroll-snapping": {
"description": "If active, the mouse wheel event on the scroller will not be caught and instead behave normally. This comes at the expense of the dotted connection lines at the top being offset wrongly more often.",
"type": "boolean",
"default": false
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions web/src/views/MainView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,13 @@ export default
scroll_item_offset = start_index + 2
visible_commits.value = filtered_commits.value.slice(scroll_item_offset, end_index)
scroller_on_wheel = (###* @type WheelEvent ### event) =>
if not store.config_scroll_snapping_active.value
return
event.preventDefault()
commits_scroller_ref.value?.scrollToItem scroll_item_offset + Math.round(event.deltaY / 20)
scroller_on_keydown = (###* @type KeyboardEvent ### event) =>
if not store.config_scroll_snapping_active.value
return
if event.key == 'ArrowDown'
event.preventDefault()
commits_scroller_ref.value?.scrollToItem scroll_item_offset + 1
Expand Down
5 changes: 5 additions & 0 deletions web/src/views/store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export selected_git_action = ref null
``###* @type {Ref<number|string>} ###
export config_width = ref ''

``###* @type {Ref<boolean>} ###
export config_scroll_snapping_active = ref false

###* @type {Ref<string[]>} ###
export folder_names = ref []

Expand All @@ -136,6 +139,8 @@ export refresh_config = =>

config_width.value = await get_config 'branch-width'

config_scroll_snapping_active.value = ! (await get_config 'disable-scroll-snapping')

export vis_v_width = computed =>
if not config_width.value or not Number(config_width.value)
Math.max(2, Math.min(10, Math.round(vis_max_length.value * (-1) * 8 / 50 + 18)))
Expand Down

0 comments on commit 1d020d5

Please sign in to comment.