Browse Source

Fix issue #1156 (#1976)

Add flag to check whether an item in the Itemset is currently being dragged
codeClimate
thomasbarone 8 years ago
committed by Alexander Wunschik
parent
commit
67823f1a7f
2 changed files with 23 additions and 0 deletions
  1. +21
    -0
      lib/timeline/Timeline.js
  2. +2
    -0
      lib/timeline/component/ItemSet.js

+ 21
- 0
lib/timeline/Timeline.js View File

@ -547,4 +547,25 @@ Timeline.prototype.getEventProperties = function (event) {
} }
}; };
/**
* Extend the drag event handler from Core, move the timeline vertically
* @param {Event} event
* @private
*/
Timeline.prototype._onDrag = function (event) {
// refuse to drag when we where pinching to prevent the timeline make a jump
// when releasing the fingers in opposite order from the touch screen, and refuse
// to drag when an item is already being dragged
if (!this.touch.allowDragging || this.itemSet.touchParams.itemIsDragging) return;
var delta = event.deltaY;
var oldScrollTop = this._getScrollTop();
var newScrollTop = this._setScrollTop(this.touch.initialScrollTop + delta);
if (newScrollTop != oldScrollTop) {
this.emit("verticalDrag");
}
};
module.exports = Timeline; module.exports = Timeline;

+ 2
- 0
lib/timeline/component/ItemSet.js View File

@ -1211,6 +1211,7 @@ ItemSet.prototype._onDragStart = function (event) {
var dragLeftItem = this.touchParams.dragLeftItem; var dragLeftItem = this.touchParams.dragLeftItem;
var dragRightItem = this.touchParams.dragRightItem; var dragRightItem = this.touchParams.dragRightItem;
this.touchParams.itemIsDragging = true;
if (dragLeftItem) { if (dragLeftItem) {
props = { props = {
@ -1494,6 +1495,7 @@ ItemSet.prototype._onDragEnd = function (event) {
var dataset = this.itemsData.getDataSet(); var dataset = this.itemsData.getDataSet();
var itemProps = this.touchParams.itemProps ; var itemProps = this.touchParams.itemProps ;
this.touchParams.itemProps = null; this.touchParams.itemProps = null;
this.touchParams.itemIsDragging = false;
itemProps.forEach(function (props) { itemProps.forEach(function (props) {
var id = props.item.id; var id = props.item.id;

Loading…
Cancel
Save