diff --git a/lib/timeline/component/ItemSet.js b/lib/timeline/component/ItemSet.js index ed27f48a..5875a46a 100644 --- a/lib/timeline/component/ItemSet.js +++ b/lib/timeline/component/ItemSet.js @@ -243,7 +243,7 @@ ItemSet.prototype._create = function(){ this.groupHammer.on('panstart', this._onGroupDragStart.bind(this)); this.groupHammer.on('panmove', this._onGroupDrag.bind(this)); this.groupHammer.on('panend', this._onGroupDragEnd.bind(this)); - this.groupHammer.get('pan').set({threshold:5, direction: Hammer.DIRECTION_HORIZONTAL}); + this.groupHammer.get('pan').set({threshold:5, direction: Hammer.DIRECTION_VERTICAL}); this.body.dom.centerContainer.addEventListener('mouseover', this._onMouseOver.bind(this)); this.body.dom.centerContainer.addEventListener('mouseout', this._onMouseOut.bind(this)); @@ -1578,6 +1578,10 @@ ItemSet.prototype._onGroupDrag = function (event) { if (this.options.groupEditable.order && this.groupTouchParams.group) { event.stopPropagation(); + var groupsData = this.groupsData; + if (this.groupsData instanceof DataView) { + groupsData = this.groupsData.getDataSet() + } // drag from one group to another var group = this.groupFromTarget(event); @@ -1602,25 +1606,23 @@ ItemSet.prototype._onGroupDrag = function (event) { } if (group && group != this.groupTouchParams.group) { - var groupsData = this.groupsData; var targetGroup = groupsData.get(group.groupId); var draggedGroup = groupsData.get(this.groupTouchParams.group.groupId); // switch groups if (draggedGroup && targetGroup) { this.options.groupOrderSwap(draggedGroup, targetGroup, this.groupsData); - this.groupsData.update(draggedGroup); - this.groupsData.update(targetGroup); + groupsData.update(draggedGroup); + groupsData.update(targetGroup); } // fetch current order of groups - var newOrder = this.groupsData.getIds({ + var newOrder = groupsData.getIds({ order: this.options.groupOrder - }); + }); // in case of changes since _onGroupDragStart if (!util.equalArray(newOrder, this.groupTouchParams.originalOrder)) { - var groupsData = this.groupsData; var origOrder = this.groupTouchParams.originalOrder; var draggedId = this.groupTouchParams.group.groupId; var numGroups = Math.min(origOrder.length, newOrder.length);