diff --git a/HISTORY.md b/HISTORY.md index 7456d461..bd3424f8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -16,6 +16,8 @@ http://visjs.org - Fixed #1001: First element of group style being cut. - Fixed #1071: HTML contents of a group not cleared when the contents is updated. +- Fixed #1033: Moved item data not updated in DataSet when using an asynchronous + `onMove` handler. ## 2015-07-03, version 4.4.0 diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index 8509c021..cd763249 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -46,7 +46,7 @@ function ItemSet(body, options) { remove: false }, - snap: TimeStep.snap, + snap: TimeStep.snap, onAdd: function (item, callback) { callback(item); @@ -1345,13 +1345,11 @@ ItemSet.prototype._onDragEnd = function (event) { if (this.touchParams.itemProps) { event.stopPropagation(); - // prepare a change set for the changed items - var changes = []; var me = this; var dataset = this.itemsData.getDataSet(); - var itemProps = this.touchParams.itemProps ; this.touchParams.itemProps = null; + itemProps.forEach(function (props) { var id = props.item.id; var exists = me.itemsData.get(id, me.itemOptions) != null; @@ -1376,7 +1374,7 @@ ItemSet.prototype._onDragEnd = function (event) { if (itemData) { // apply changes itemData[dataset._fieldId] = id; // ensure the item contains its id (can be undefined) - changes.push(itemData); + dataset.update(itemData); } else { // restore original values @@ -1388,11 +1386,6 @@ ItemSet.prototype._onDragEnd = function (event) { }); } }); - - // apply the changes to the data (if there are changes) - if (changes.length) { - dataset.update(changes); - } } };