Browse Source

Fixed `onMoving` not normalizing the dates again after callback

webworkersNetwork
jos 9 years ago
parent
commit
637fc3fd87
1 changed files with 9 additions and 5 deletions
  1. +9
    -5
      lib/timeline/component/ItemSet.js

+ 9
- 5
lib/timeline/component/ItemSet.js View File

@ -1384,9 +1384,9 @@ ItemSet.prototype._onDrag = function (event) {
itemData = this._cloneItemData(itemData); // convert start and end to the correct type itemData = this._cloneItemData(itemData); // convert start and end to the correct type
me.options.onMoving(itemData, function (itemData) { me.options.onMoving(itemData, function (itemData) {
if (itemData) { if (itemData) {
props.item.setData(itemData);
props.item.setData(this._cloneItemData(itemData, 'Date'));
} }
});
}.bind(this));
}.bind(this)); }.bind(this));
this.stackDirty = true; // force re-stacking of all items next redraw this.stackDirty = true; // force re-stacking of all items next redraw
@ -1908,14 +1908,18 @@ ItemSet.itemSetFromTarget = function(event) {
* to the type (Date, Moment, ...) configured in the DataSet. If not configured, * to the type (Date, Moment, ...) configured in the DataSet. If not configured,
* start and end are converted to Date. * start and end are converted to Date.
* @param {Object} itemData, typically `item.data` * @param {Object} itemData, typically `item.data`
* @param {string} [type] Optional Date type. If not provided, the type from the DataSet is taken
* @return {Object} The cloned object * @return {Object} The cloned object
* @private * @private
*/ */
ItemSet.prototype._cloneItemData = function (itemData) {
ItemSet.prototype._cloneItemData = function (itemData, type) {
var clone = util.extend({}, itemData); var clone = util.extend({}, itemData);
// convert start and end date to the type (Date, Moment, ...) configured in the DataSet
var type = this.itemsData.getDataSet()._options.type;
if (!type) {
// convert start and end date to the type (Date, Moment, ...) configured in the DataSet
type = this.itemsData.getDataSet()._options.type;
}
if (clone.start != undefined) { if (clone.start != undefined) {
clone.start = util.convert(clone.start, type && type.start || 'Date'); clone.start = util.convert(clone.start, type && type.start || 'Date');
} }

Loading…
Cancel
Save