Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
move(delta: number) {
delta = this.hasScroll ? delta : 0
this.movingDirection =
delta > 0
? Direction.Negative
: delta < 0
? Direction.Positive
: Direction.Default
let newPos = this.currentPos + delta
// Slow down or stop if outside of the boundaries
if (newPos > this.minScrollPos || newPos < this.maxScrollPos) {
if (
(newPos > this.minScrollPos && this.options.bounces[0]) ||
(newPos < this.maxScrollPos && this.options.bounces[1])
) {
newPos = this.currentPos + delta / 3
} else {
newPos =
newPos > this.minScrollPos ? this.minScrollPos : this.maxScrollPos
}
}
return newPos
updateDirection() {
const absDist = Math.round(this.currentPos) - this.absStartPos
this.direction =
absDist > 0
? Direction.Negative
: absDist < 0
? Direction.Positive
: Direction.Default
}
start() {
this.direction = Direction.Default
this.movingDirection = Direction.Default
this.dist = 0
}
start() {
this.direction = Direction.Default
this.movingDirection = Direction.Default
this.dist = 0
}