Added throwDaping instance variable to fix throw behavior

This commit is contained in:
Uwe Oestermeier 2019-05-14 09:57:28 +02:00
parent b07d76ce1d
commit 06e69d86b6

View File

@ -476,7 +476,7 @@ export class ColorRanges {
export default class Timeline extends BitmapLabeledGraphics { export default class Timeline extends BitmapLabeledGraphics {
constructor(width, height, { ticks = null, constructor(width, height, { ticks = null,
baseLine = 0.5, showRange = true } = {}) { baseLine = 0.5, showRange = true, throwDamping = 0.95 } = {}) {
super() super()
this.wantedWidth = width this.wantedWidth = width
this.wantedHeight = height this.wantedHeight = height
@ -507,6 +507,7 @@ export default class Timeline extends BitmapLabeledGraphics {
this.selection = null this.selection = null
this.autoScroll = false this.autoScroll = false
this.direction = -1 this.direction = -1
this.throwDamping = throwDamping
this.timeticks = ticks || new TimeTicks(new DecadeTicks(), this.timeticks = ticks || new TimeTicks(new DecadeTicks(),
new YearTicks(), new YearTicks(),
new MonthTicks(), new MonthTicks(),
@ -884,7 +885,7 @@ export default class Timeline extends BitmapLabeledGraphics {
return return
} }
this.scroll += delta this.scroll += delta
delta *= 0.985 delta *= this.throwDamping
this.redraw() this.redraw()
if (Math.abs(delta) > 1 && this.autoScroll) { if (Math.abs(delta) > 1 && this.autoScroll) {
setTimeout(() => this.keepInBounds(delta, anchor), 1000 / 100) setTimeout(() => this.keepInBounds(delta, anchor), 1000 / 100)