Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1021 from geoadmin/fix_1016
Browse files Browse the repository at this point in the history
Prevent default behavior on each event of draggable directive
  • Loading branch information
gjn committed Jan 30, 2014
2 parents 6f58ae5 + ef309f1 commit e148f07
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/DraggableDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
return function(scope, element, attr) {
var startX = 0, startY = 0, x = null, y = null;
var eventKey = gaBrowserSniffer.events;
var regex = /^(input|textarea|a|button)$/i;

// Firefox doesn't like transition during drag
element.addClass('ga-draggable');
Expand All @@ -44,8 +45,8 @@
y = element.prop('offsetTop');


// block user interaction
if (/^(input|textarea|a|button)$/i.test(evt.target.nodeName)) {
// block default interaction
if (!regex.test(evt.target.nodeName)) {
evt.preventDefault();
}

Expand Down Expand Up @@ -76,11 +77,21 @@
top: y + 'px',
left: x + 'px'
});

// block default interaction
if (!regex.test(evt.target.nodeName)) {
evt.preventDefault();
}
}

function dragend() {
function dragend(evt) {
$document.unbind(eventKey.move, drag);
$document.unbind(eventKey.end, dragend);

// block default interaction
if (!regex.test(evt.target.nodeName)) {
evt.preventDefault();
}
}


Expand Down

0 comments on commit e148f07

Please sign in to comment.