Browse Source

Several changes to get the performance on dragging back in check.

codeClimate
Ludo Stellingwerff 9 years ago
parent
commit
8f4e9e9c8f
3 changed files with 9 additions and 9 deletions
  1. +3
    -2
      lib/timeline/Core.js
  2. +6
    -2
      lib/timeline/Range.js
  3. +0
    -5
      lib/timeline/component/LineGraph.js

+ 3
- 2
lib/timeline/Core.js View File

@ -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");
}
};

+ 6
- 2
lib/timeline/Range.js View File

@ -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
});
};

+ 0
- 5
lib/timeline/component/LineGraph.js View File

@ -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;

Loading…
Cancel
Save