mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Improve smooth scroll
This commit is contained in:
parent
293ec5503f
commit
c251fb4788
1 changed files with 6 additions and 3 deletions
|
@ -87,12 +87,15 @@ class ScrollingData {
|
|||
}
|
||||
|
||||
scroll(distance: number, duration: number) {
|
||||
this.duration = duration
|
||||
this.startTime = performance.now()
|
||||
this.startPos = this.elem[this.pos]
|
||||
// If we're already scrolling, update the endPos based off the current endPos
|
||||
if (this.scrolling) {
|
||||
this.endPos = this.endPos + distance
|
||||
return true
|
||||
}
|
||||
this.endPos = this.startPos + distance
|
||||
this.duration = duration
|
||||
// If we're already scrolling we don't need to try to scroll
|
||||
if (this.scrolling) return true
|
||||
if ("style" in this.elem)
|
||||
(this.elem as any).style.scrollBehavior = "unset"
|
||||
this.scrolling = this.scrollStep()
|
||||
|
|
Loading…
Add table
Reference in a new issue