fatlinesofcode / ngDraggable

Drag and drop module for Angular JS
MIT License
631 stars 400 forks source link

avoid ng-click after drag end #188

Closed CrackerakiUA closed 7 years ago

CrackerakiUA commented 9 years ago

i have ng-click on the ng-drag element, when i am starting to move the element it's everything ok, but when i stop it, that element activate my ng-click, how can i avoid that ng-click?

CrackerakiUA commented 9 years ago

If the draggable is also clickable (ng-click, ng-dblclick) the script wont react. What do you mean by that?

bblack commented 9 years ago

Also curious about conditionally preventing going to the href, in the case that the draggable element is an <a> element.

MichalJakubeczy commented 8 years ago

I overcame it by adding ng-drag-start and ng-drag-stop handlers on dragged element.

ng-drag-start handler sets isDragging auxiliary property to true ng-drag-stop handler sets isDragging auxiliary property to false (do it in a timeout to occur after current digest cycle)

ng-click handler executes only in case isDragging is false.

Works for me.

sauliuni commented 7 years ago

@MichalJakubeczy how did you manage to get the ng-click to work?

CrackerakiUA commented 7 years ago

@sauliuni have an variable which get true when drag start, and get false when drag ends on timeout something like 300ms. On ngClick check that variable.