Browse Source

redraw on data change is now done on next tick, so you have only one redraw for multiple (synchronous) changes

v3_develop
jos 9 years ago
parent
commit
ba6e05486e
2 changed files with 23 additions and 8 deletions
  1. +17
    -2
      lib/timeline/Core.js
  2. +6
    -6
      lib/timeline/component/ItemSet.js

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

@ -92,12 +92,28 @@ Core.prototype._create = function (container) {
this.dom.rightContainer.appendChild(this.dom.shadowBottomRight);
this.on('rangechange', this.redraw.bind(this));
this.on('change', this.redraw.bind(this));
this.on('touch', this._onTouch.bind(this));
this.on('pinch', this._onPinch.bind(this));
this.on('dragstart', this._onDragStart.bind(this));
this.on('drag', this._onDrag.bind(this));
var me = this;
this.on('change', function (properties) {
if (properties && properties.queue == true) {
// redraw once on next tick
if (!me._redrawTimer) {
me._redrawTimer = setTimeout(function () {
me._redrawTimer = null;
me.redraw();
}, 0)
}
}
else {
// redraw immediately
me.redraw();
}
});
// create event listeners for all interesting events, these events will be
// emitted via emitter
this.hammer = Hammer(this.dom.root, {
@ -105,7 +121,6 @@ Core.prototype._create = function (container) {
});
this.listeners = {};
var me = this;
var events = [
'touch', 'pinch',
'tap', 'doubletap', 'hold',

+ 6
- 6
lib/timeline/component/ItemSet.js View File

@ -720,7 +720,7 @@ ItemSet.prototype.setGroups = function(groups) {
// update the order of all items in each group
this._order();
this.body.emitter.emit('change');
this.body.emitter.emit('change', {queue: true});
};
/**
@ -825,7 +825,7 @@ ItemSet.prototype._onUpdate = function(ids) {
this._order();
this.stackDirty = true; // force re-stacking of all items next redraw
this.body.emitter.emit('change');
this.body.emitter.emit('change', {queue: true});
};
/**
@ -855,7 +855,7 @@ ItemSet.prototype._onRemove = function(ids) {
// update order
this._order();
this.stackDirty = true; // force re-stacking of all items next redraw
this.body.emitter.emit('change');
this.body.emitter.emit('change', {queue: true});
}
};
@ -881,7 +881,7 @@ ItemSet.prototype._onUpdateGroups = function(ids) {
};
/**
* Handle changed groups
* Handle changed groups (added or updated)
* @param {Number[]} ids
* @private
*/
@ -925,7 +925,7 @@ ItemSet.prototype._onAddGroups = function(ids) {
}
});
this.body.emitter.emit('change');
this.body.emitter.emit('change', {queue: true});
};
/**
@ -946,7 +946,7 @@ ItemSet.prototype._onRemoveGroups = function(ids) {
this.markDirty();
this.body.emitter.emit('change');
this.body.emitter.emit('change', {queue: true});
};
/**

Loading…
Cancel
Save