From 8f4e9e9c8f5ff2c2c56cd0df8ee1395aa49f379b Mon Sep 17 00:00:00 2001 From: Ludo Stellingwerff Date: Fri, 29 Jan 2016 09:24:52 +0100 Subject: [PATCH] Several changes to get the performance on dragging back in check. --- lib/timeline/Core.js | 5 +++-- lib/timeline/Range.js | 8 ++++++-- lib/timeline/component/LineGraph.js | 5 ----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/timeline/Core.js b/lib/timeline/Core.js index fab24763..5b8750ef 100644 --- a/lib/timeline/Core.js +++ b/lib/timeline/Core.js @@ -29,6 +29,7 @@ Emitter(Core.prototype); */ Core.prototype._create = function (container) { this.dom = {}; + this.options = {}; this.dom.container = container; @@ -91,7 +92,7 @@ Core.prototype._create = function (container) { this.dom.rightContainer.appendChild(this.dom.shadowBottomRight); this.on('rangechange', function () { - if (this.initialDrawDone) { + if (this.initialDrawDone === true) { this._redraw(); // this allows overriding the _redraw method } }.bind(this)); @@ -226,6 +227,7 @@ Core.prototype.setOptions = function (options) { ]; util.selectiveExtend(fields, this.options, options); + this.options.orientation = {item:undefined,axis:undefined}; if ('orientation' in options) { if (typeof options.orientation === 'string') { this.options.orientation = { @@ -986,7 +988,6 @@ Core.prototype._onDrag = function (event) { if (newScrollTop != oldScrollTop) { - this._redraw(); // TODO: this causes two redraws when dragging, the other is triggered by rangechange already this.emit("verticalDrag"); } }; diff --git a/lib/timeline/Range.js b/lib/timeline/Range.js index 0564f885..97e690e2 100644 --- a/lib/timeline/Range.js +++ b/lib/timeline/Range.js @@ -429,10 +429,14 @@ Range.prototype._onDrag = function (event) { this.previousDelta = delta; this._applyRange(newStart, newEnd); + + var startDate = new Date(this.start); + var endDate = new Date(this.end); + // fire a rangechange event this.body.emitter.emit('rangechange', { - start: new Date(this.start), - end: new Date(this.end), + start: startDate, + end: endDate, byUser: true }); }; diff --git a/lib/timeline/component/LineGraph.js b/lib/timeline/component/LineGraph.js index f2be089b..1af1f1b8 100644 --- a/lib/timeline/component/LineGraph.js +++ b/lib/timeline/component/LineGraph.js @@ -509,11 +509,6 @@ LineGraph.prototype.redraw = function () { - this.body.domProps.border.top - this.body.domProps.border.bottom; - // update the graph if there is no lastWidth or width, used for the initial draw - if (this.lastWidth === undefined && this.props.width) { - this.forceGraphUpdate = true; - } - // check if this component is resized resized = this._isResized() || resized;