Timeline is now draggable
This commit is contained in:
+12
-9
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { Cycle, Colors, Dates, isEmpty } from '../utils.js'
|
||||
import { Capabilities } from '../capabilities.js'
|
||||
import { BitmapLabeledGraphics, FontInfo } from './labeledgraphics.js'
|
||||
@@ -495,6 +496,7 @@ export default class Timeline extends BitmapLabeledGraphics {
|
||||
this.minZoom = 1
|
||||
this.maxZoom = 12000
|
||||
this.scroll = 0
|
||||
this.draggable = false
|
||||
this.deltas = []
|
||||
this.labelDates = []
|
||||
this.colorRanges = []
|
||||
@@ -761,9 +763,9 @@ export default class Timeline extends BitmapLabeledGraphics {
|
||||
this.killTweens()
|
||||
this.deltas = []
|
||||
this.validScroll()
|
||||
if (typeof ThrowPropsPlugin != 'undefined') {
|
||||
ThrowPropsPlugin.track(this, 'delta')
|
||||
}
|
||||
// if (typeof ThrowPropsPlugin != 'undefined') {
|
||||
// ThrowPropsPlugin.track(this, 'delta')
|
||||
// }
|
||||
}
|
||||
|
||||
onMove(event, interaction) {
|
||||
@@ -772,6 +774,9 @@ export default class Timeline extends BitmapLabeledGraphics {
|
||||
return
|
||||
}
|
||||
this.scroll += delta.x
|
||||
if (this.draggable) {
|
||||
this.y += delta.y
|
||||
}
|
||||
while (this.deltas.length > 10) {
|
||||
this.deltas.pop(0)
|
||||
}
|
||||
@@ -783,11 +788,10 @@ export default class Timeline extends BitmapLabeledGraphics {
|
||||
}
|
||||
|
||||
onEnd(event, interaction) {
|
||||
if (typeof ThrowPropsPlugin != 'undefined') {
|
||||
let vel = ThrowPropsPlugin.getVelocity(this, 'delta')
|
||||
ThrowPropsPlugin.untrack(this)
|
||||
}
|
||||
|
||||
// if (typeof ThrowPropsPlugin != 'undefined') {
|
||||
// let vel = ThrowPropsPlugin.getVelocity(this, 'delta')
|
||||
// ThrowPropsPlugin.untrack(this)
|
||||
// }
|
||||
this.killTweens()
|
||||
this.redraw()
|
||||
let delta = 0
|
||||
@@ -800,7 +804,6 @@ export default class Timeline extends BitmapLabeledGraphics {
|
||||
this.autoScroll = true
|
||||
let anchor = interaction.current.mean()
|
||||
this.keepInBounds(delta, anchor)
|
||||
|
||||
for (let key of interaction.ended.keys()) {
|
||||
if (interaction.isDoubleTap(key)) {
|
||||
this.onDoubleTap(event, interaction, key)
|
||||
|
||||
Reference in New Issue
Block a user