Skip to content

Feat: Added one panel switch per scroll setting #1424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 24, 2024
Merged

Conversation

ImTheSquid
Copy link
Contributor

Added an option in settings to only allow for one panel switch when using the horizontal scroll to switch feature, similar to how Arc works. I added the base English translation for the text.

@mbnuqw
Copy link
Owner

mbnuqw commented Jan 22, 2024

Thanks. I think it would be better if we moved your debouncing algorithm to Sidebar.switchPanel to avoid double debouncing. Plus, there is already a setting for configuring specific delay time navSwitchPanelsDelay (50ms on my hardware was not enough).

Something like that (in sidebar.actions.ts):

function startPanelSwitchingDebounceTimer(delay: number) {
  switchPanelPause = setTimeout(() => {
    clearTimeout(switchPanelPause)
    switchPanelPause = undefined
  }, delay)
}

let switchPanelPause: number | undefined
export function switchPanel(
  dir: 1 | -1,
  ignoreHidden?: boolean,
  withoutTabCreation?: boolean,
  restartDebouncer?: boolean
): void {
  // Debounce switching
  const delay = Settings.state.navSwitchPanelsDelay ?? 128
  if (switchPanelPause) {
    if (restartDebouncer) { // + check switched scroll direction
      clearTimeout(switchPanelPause)
      startPanelSwitchingDebounceTimer(delay)
    }
    return
  }
  if (delay > 0) startPanelSwitchingDebounceTimer(delay)

//...

And that (in sidebar.vue):

  if (e.deltaX > 0) return Sidebar.switchPanel(1, true, false, Settings.state.onePanelSwitchPerScroll)
  if (e.deltaX < 0) return Sidebar.switchPanel(-1, true, false, Settings.state.onePanelSwitchPerScroll)

@ImTheSquid
Copy link
Contributor Author

Makes sense, I'll switch it over.

@mbnuqw mbnuqw merged commit 7a71dd4 into mbnuqw:v5 Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants