Skip to content

Commit

Permalink
use auto scroll instead of smooth to avoid lagging in repeating scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
taquangtrung committed Jan 2, 2024
1 parent e9da179 commit 8cbb853
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions viewer/latexworkshop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,15 @@ class LateXWorkshopPdfViewer implements ILatexWorkshopPdfViewer {
const container = document.getElementById('viewerContainer') as HTMLElement

const configMap: {[key: string]: ScrollToOptions} = {
'J': { top: evt.repeat ? 20 : 40 },
'K': { top: evt.repeat ? -20 : -40 },
'H': { left: evt.repeat ? -20 : -40 },
'L': { left: evt.repeat ? 20 : 40 },
'J': { top: evt.repeat ? 30 : 40 },
'K': { top: evt.repeat ? -30 : -40 },
'H': { left: evt.repeat ? -30 : -40 },
'L': { left: evt.repeat ? 30 : 40 },
}
const behavior = evt.repeat ? 'auto' : 'smooth'

if (configMap[evt.key]) {
container.scrollBy({ ...configMap[evt.key], behavior: 'smooth' })
container.scrollBy({ ...configMap[evt.key], behavior })
}
}
})
Expand Down

0 comments on commit 8cbb853

Please sign in to comment.