Skip to content

Instantly share code, notes, and snippets.

@elqsar
Created December 9, 2014 16:06
Show Gist options
  • Save elqsar/0cdfc0a66beb897aac3d to your computer and use it in GitHub Desktop.
Save elqsar/0cdfc0a66beb897aac3d to your computer and use it in GitHub Desktop.
Allow user copy paste text without triggering modal open in Angular directive
function link(scope, element, attr) {
var isDragging = false;
element.addClass('cursor-pointer');
element.on('mousedown', function(){
element.on('mousemove', function(){
isDragging = true;
element.unbind('mousemove');
});
});
element.on('mouseup', function(){
var wasDragging = isDragging;
isDragging = false;
element.unbind('mousemove');
if(!wasDragging) {
$modal.open({
// some logic
}).result.then(function (result) {
// some logic
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment