Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
clamp scroll position before emitting scroll event
Browse files Browse the repository at this point in the history
fixes #44
  • Loading branch information
ashthornton committed May 1, 2021
1 parent 3e99f4f commit 5fcc42b
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/Scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export default class Scroll {
this.scrolling = false
this.syncScroll = false
this.deltaY = 0
this.wheeling = false
this.wheel = true
this.horizontalScroll = false
this.touchScroll = false
this.firstResize = true
Expand Down Expand Up @@ -103,9 +101,10 @@ export default class Scroll {
event.preventDefault()

this.deltaY = normalizeWheel(event).pixelY
this.wheeling = true
this.syncScroll = true
this.wheel = true
this.scrollPos += this.deltaY * -1
this.clamp()
E.emit(Store.events.COMBOSCROLL, this.scrollPos)

return

Expand All @@ -122,10 +121,11 @@ export default class Scroll {
this.scrollPos = -window.scrollY
}

this.wheel = false
if( Store.isTouch && this.options.disableOnTouch ) {
this.smoothScrollPos = this.scrollPos
}

this.clamp()
E.emit(Store.events.COMBOSCROLL, this.scrollPos)
}

Expand All @@ -135,14 +135,6 @@ export default class Scroll {

if( !this.render ) return

if( this.wheeling ) {
this.scrollPos += this.deltaY * -1
this.wheeling = false
E.emit(Store.events.COMBOSCROLL, this.scrollPos)
}

this.clamp()

if (this.options.limitLerpRate) {
this.time = performance.now() * 0.001
this.delta = Math.min((this.time - this.startTime) * 60, 1)
Expand Down

0 comments on commit 5fcc42b

Please sign in to comment.