Browse Source

fixes #2367 Group editable bug (#2368)

* Fix groupEditable
* Fix group drag in vertical direction bug
* Fix indentation
codeClimate
yotamberk 8 years ago
committed by Alexander Wunschik
parent
commit
4d7a21c847
1 changed files with 9 additions and 7 deletions
  1. +9
    -7
      lib/timeline/component/ItemSet.js

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

@ -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);

Loading…
Cancel
Save