From 9553bd08b7f8344f48a93c985d7c2bcb74a5a68e Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Wed, 24 Jun 2015 14:14:46 -0400 Subject: [PATCH] dismiss HTML5 drag events with jQuery dragging Fixes #206 --- changelog.md | 2 ++ js/packery.js | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index f1a0bd3..48c58c6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ # Changelog ++ Fixed bug with HTML5 drag & drop. Fixed [#206](https://github.com/metafizzy/packery/issues/206) + ### v1.4.1 + Remove `instance` argument from `dragItemPositioned` and `fitComplete` events diff --git a/js/packery.js b/js/packery.js index 01613e0..028049a 100644 --- a/js/packery.js +++ b/js/packery.js @@ -86,13 +86,23 @@ Packery.prototype._create = function() { }; this.handleUIDraggable = { - start: function handleUIDraggableStart( event ) { + start: function handleUIDraggableStart( event, ui ) { + // HTML5 may trigger dragstart, dismiss HTML5 dragging + if ( !ui ) { + return; + } _this.itemDragStart( event.currentTarget ); }, drag: function handleUIDraggableDrag( event, ui ) { + if ( !ui ) { + return; + } _this.itemDragMove( event.currentTarget, ui.position.left, ui.position.top ); }, - stop: function handleUIDraggableStop( event ) { + stop: function handleUIDraggableStop( event, ui ) { + if ( !ui ) { + return; + } _this.itemDragEnd( event.currentTarget ); } };