From 297adb1cb4844b403f6eb6481aefb0e23f746cfe Mon Sep 17 00:00:00 2001 From: jos Date: Tue, 10 Jun 2014 12:18:17 +0200 Subject: [PATCH] A minor improvement in dragging items --- src/timeline/component/ItemSet.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/timeline/component/ItemSet.js b/src/timeline/component/ItemSet.js index fb1fce19..48337f45 100644 --- a/src/timeline/component/ItemSet.js +++ b/src/timeline/component/ItemSet.js @@ -113,6 +113,7 @@ ItemSet.prototype._create = function _create(){ }); // drag items when selected + this.hammer.on('touch', this._onTouch.bind(this)); this.hammer.on('dragstart', this._onDragStart.bind(this)); this.hammer.on('drag', this._onDrag.bind(this)); this.hammer.on('dragend', this._onDragEnd.bind(this)); @@ -836,6 +837,20 @@ ItemSet.prototype.getLabelsWidth = function getLabelsWidth() { return width; }; +/** + * Register the clicked item on touch, before dragStart is initiated. + * + * dragStart is initiated from a mousemove event, which can have left the item + * already resulting in an item == null + * + * @param {Event} event + * @private + */ +ItemSet.prototype._onTouch = function (event) { + // store the touched item, used in _onDragStart + this.touchParams.item = ItemSet.itemFromTarget(event); +}; + /** * Start dragging the selected events * @param {Event} event @@ -846,7 +861,7 @@ ItemSet.prototype._onDragStart = function (event) { return; } - var item = ItemSet.itemFromTarget(event), + var item = this.touchParams.item || null, me = this, props;