From 9aef7bb460fc3e9c1524bcb5c687820314002c9c Mon Sep 17 00:00:00 2001 From: Uwe Oestermeier Date: Thu, 8 Aug 2019 12:06:16 +0200 Subject: [PATCH] Timeline is now draggable --- dist/iwmlib.pixi.js | 21 +++++++++++---------- lib/pixi/buttongroup.js | 1 - lib/pixi/scatter.js | 3 +-- lib/pixi/timeline.js | 21 ++++++++++++--------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index 7d9c091..2e0242f 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -3444,7 +3444,6 @@ // stack! const distanceToTop = this.container.y; const distanceToBottom = this.opts.maxHeight - this.container.y - this.__initHeight; - if (distanceToTop > 0) { throwProps.y.end = 0; } else if (distanceToBottom > 0) { @@ -12325,6 +12324,8 @@ } } + /* global ThrowPropsPlugin */ + class Ticks { get reservedPrefixes() { return ['decade', 'year', 'month', 'day', 'hour', 'minute', 'second'] @@ -12983,9 +12984,9 @@ 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) { @@ -13005,11 +13006,11 @@ } 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; @@ -13022,7 +13023,7 @@ this.autoScroll = true; let anchor = interaction.current.mean(); this.keepInBounds(delta, anchor); - + console.log("onEnd", delta); for (let key of interaction.ended.keys()) { if (interaction.isDoubleTap(key)) { this.onDoubleTap(event, interaction, key); diff --git a/lib/pixi/buttongroup.js b/lib/pixi/buttongroup.js index 2eef1a8..3a4723c 100644 --- a/lib/pixi/buttongroup.js +++ b/lib/pixi/buttongroup.js @@ -506,7 +506,6 @@ export default class ButtonGroup extends PIXI.Container { // stack! const distanceToTop = this.container.y const distanceToBottom = this.opts.maxHeight - this.container.y - this.__initHeight - if (distanceToTop > 0) { throwProps.y.end = 0 } else if (distanceToBottom > 0) { diff --git a/lib/pixi/scatter.js b/lib/pixi/scatter.js index 9b43d03..a84f05a 100755 --- a/lib/pixi/scatter.js +++ b/lib/pixi/scatter.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ import Events from '../events.js' import { AbstractScatter } from '../scatter.js' import { Angle, Points, Polygon } from '../utils.js' @@ -333,8 +334,6 @@ export class DisplayObjectScatter extends AbstractScatter { roundPixel(value) { // UO: Should be obsolete because Renderer supports roundPixels by default return value - let res = this.renderer.resolution - return Math.round(value * res) / res } get container() { diff --git a/lib/pixi/timeline.js b/lib/pixi/timeline.js index 209481d..6dbf032 100644 --- a/lib/pixi/timeline.js +++ b/lib/pixi/timeline.js @@ -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)