Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ngDraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,21 @@ angular.module("ngDraggable", [])
}
};

var hitTest = function(x, y) {
var hitTest = function(x, y) {
var bounds = element[0].getBoundingClientRect();// ngDraggable.getPrivOffset(element);
x -= $document[0].body.scrollLeft + $document[0].documentElement.scrollLeft;
y -= $document[0].body.scrollTop + $document[0].documentElement.scrollTop;

var draggingElmt = document.getElementsByClassName("dragging")[0];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bug here. When a user clicks on a draggable element without dragging it an exception is thrown in the console.

var display = draggingElmt.style.display;
draggingElmt.style.display = 'none';
var isTopElement = document.elementFromPoint(x, y) == element[0] || element[0].contains( document.elementFromPoint(x, y) );;
draggingElmt.style.display = display;

return x >= bounds.left
&& x <= bounds.right
&& y <= bounds.bottom
&& y >= bounds.top;
&& y >= bounds.top && isTopElement;
};

initialize();
Expand Down