mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Merge branch 'fix_smooth_scrolling'
This commit is contained in:
commit
d5872f7b64
1 changed files with 13 additions and 3 deletions
|
@ -54,9 +54,19 @@ class ScrollingData {
|
|||
if (elapsed >= this.duration || this.elem[this.pos] === this.endPos)
|
||||
return this.endPos
|
||||
|
||||
const result = ((this.endPos - this.startPos) * elapsed) / this.duration
|
||||
if (result >= 1 || result <= -1) return this.startPos + result
|
||||
return this.elem[this.pos] + (this.startPos < this.endPos ? 1 : -1)
|
||||
let result = this.startPos + (((this.endPos - this.startPos) * elapsed) / this.duration)
|
||||
if (this.startPos < this.endPos) {
|
||||
// We need to ceil() because only highdpi screens have a decimal this.elem[this.pos]
|
||||
result = Math.ceil(result)
|
||||
// We *have* to make progress, otherwise we'll think the element can't be scrolled
|
||||
if (result == this.elem[this.pos])
|
||||
result += 1
|
||||
} else {
|
||||
result = Math.floor(result)
|
||||
if (result == this.elem[this.pos])
|
||||
result -= 1
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** Updates the position of this.elem, returns true if the element has been scrolled, false otherwise. */
|
||||
|
|
Loading…
Add table
Reference in a new issue