|
@ -243,7 +243,7 @@ ItemSet.prototype._create = function(){ |
|
|
this.groupHammer.on('panstart', this._onGroupDragStart.bind(this)); |
|
|
this.groupHammer.on('panstart', this._onGroupDragStart.bind(this)); |
|
|
this.groupHammer.on('panmove', this._onGroupDrag.bind(this)); |
|
|
this.groupHammer.on('panmove', this._onGroupDrag.bind(this)); |
|
|
this.groupHammer.on('panend', this._onGroupDragEnd.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('mouseover', this._onMouseOver.bind(this)); |
|
|
this.body.dom.centerContainer.addEventListener('mouseout', this._onMouseOut.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) { |
|
|
if (this.options.groupEditable.order && this.groupTouchParams.group) { |
|
|
event.stopPropagation(); |
|
|
event.stopPropagation(); |
|
|
|
|
|
|
|
|
|
|
|
var groupsData = this.groupsData; |
|
|
|
|
|
if (this.groupsData instanceof DataView) { |
|
|
|
|
|
groupsData = this.groupsData.getDataSet() |
|
|
|
|
|
} |
|
|
// drag from one group to another
|
|
|
// drag from one group to another
|
|
|
var group = this.groupFromTarget(event); |
|
|
var group = this.groupFromTarget(event); |
|
|
|
|
|
|
|
@ -1602,25 +1606,23 @@ ItemSet.prototype._onGroupDrag = function (event) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (group && group != this.groupTouchParams.group) { |
|
|
if (group && group != this.groupTouchParams.group) { |
|
|
var groupsData = this.groupsData; |
|
|
|
|
|
var targetGroup = groupsData.get(group.groupId); |
|
|
var targetGroup = groupsData.get(group.groupId); |
|
|
var draggedGroup = groupsData.get(this.groupTouchParams.group.groupId); |
|
|
var draggedGroup = groupsData.get(this.groupTouchParams.group.groupId); |
|
|
|
|
|
|
|
|
// switch groups
|
|
|
// switch groups
|
|
|
if (draggedGroup && targetGroup) { |
|
|
if (draggedGroup && targetGroup) { |
|
|
this.options.groupOrderSwap(draggedGroup, targetGroup, this.groupsData); |
|
|
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
|
|
|
// fetch current order of groups
|
|
|
var newOrder = this.groupsData.getIds({ |
|
|
|
|
|
|
|
|
var newOrder = groupsData.getIds({ |
|
|
order: this.options.groupOrder |
|
|
order: this.options.groupOrder |
|
|
}); |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// in case of changes since _onGroupDragStart
|
|
|
// in case of changes since _onGroupDragStart
|
|
|
if (!util.equalArray(newOrder, this.groupTouchParams.originalOrder)) { |
|
|
if (!util.equalArray(newOrder, this.groupTouchParams.originalOrder)) { |
|
|
var groupsData = this.groupsData; |
|
|
|
|
|
var origOrder = this.groupTouchParams.originalOrder; |
|
|
var origOrder = this.groupTouchParams.originalOrder; |
|
|
var draggedId = this.groupTouchParams.group.groupId; |
|
|
var draggedId = this.groupTouchParams.group.groupId; |
|
|
var numGroups = Math.min(origOrder.length, newOrder.length); |
|
|
var numGroups = Math.min(origOrder.length, newOrder.length); |
|
@ -1854,12 +1856,12 @@ ItemSet.prototype._onAddItem = function (event) { |
|
|
newItemData[this.itemsData._fieldId] = itemData.id || util.randomUUID(); |
|
|
newItemData[this.itemsData._fieldId] = itemData.id || util.randomUUID(); |
|
|
|
|
|
|
|
|
if (itemData.type == 'range' || (itemData.end && itemData.start)) { |
|
|
if (itemData.type == 'range' || (itemData.end && itemData.start)) { |
|
|
|
|
|
|
|
|
if (!itemData.end) { |
|
|
if (!itemData.end) { |
|
|
var end = this.body.util.toTime(x + this.props.width / 5); |
|
|
var end = this.body.util.toTime(x + this.props.width / 5); |
|
|
newItemData.end = snap ? snap(end, scale, step) : end; |
|
|
newItemData.end = snap ? snap(end, scale, step) : end; |
|
|
} else { |
|
|
} else { |
|
|
newItemData.end = new Date(newItemData.start._i).getTime() + new Date(itemData.end).getTime() - new Date(itemData.start).getTime(); |
|
|
|
|
|
|
|
|
newItemData.end = itemData.end; |
|
|
|
|
|
newItemData.start = itemData.start; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|