Skip to content

Commit

Permalink
actions/drop: check dragRect before using it
Browse files Browse the repository at this point in the history
Close #450
  • Loading branch information
taye committed Nov 28, 2016
1 parent 03396e0 commit bb503b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/actions/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@ Interactable.prototype.dropCheck = function (dragEvent, event, draggable, dragga

const dragRect = draggable.getRect(draggableElement);

if (dropOverlap === 'center') {
if (dragRect && dropOverlap === 'center') {
const cx = dragRect.left + dragRect.width / 2;
const cy = dragRect.top + dragRect.height / 2;

dropped = cx >= rect.left && cx <= rect.right && cy >= rect.top && cy <= rect.bottom;
}

if (utils.isNumber(dropOverlap)) {
if (dragRect && utils.isNumber(dropOverlap)) {
const overlapArea = (Math.max(0, Math.min(rect.right , dragRect.right ) - Math.max(rect.left, dragRect.left))
* Math.max(0, Math.min(rect.bottom, dragRect.bottom) - Math.max(rect.top , dragRect.top )));

Expand Down

0 comments on commit bb503b5

Please sign in to comment.