angular-drag-drop icon indicating copy to clipboard operation
angular-drag-drop copied to clipboard

Issue with nested drop elements

Open apinstein opened this issue 11 years ago • 5 comments

I tried out your lib for a dnd implementation I needed... I'm not doing your normal "sortable" and needed custom drag & drop zones and your codebase seemed nicely factored for this use case.

For my use case, there's a parent/child relationship:

<div drop="moveToRoot">
   <div drop="moveUnderChild" drag ng-model="story">
         Root Story 1
         <div drag ng-model="story">Child Story 1</div>
  </div>
   <div drop="moveUnderChild" drag ng-model="story">
         Root Story 2
  </div>
</div>

It worked fine for moving Child Story 1 to Root Story 2, but failed to allow dropping on the "moveToRoot" container. I narrowed it down to this line:

https://github.com/fisshy/angular-drag-drop/blob/master/angular-dnd.js#L30

I'm not sure what this LOC does, but by making it just add the class to the el no matter what, it solved my problem.

Would love to help tidy it up for you if you could elucidate its function.

apinstein avatar Jan 28 '14 19:01 apinstein

What I wanted to solve was so you couldn't drop the element back at owner because then it would copy itself.

So what it does is to check if the parent is the same of the item thats being dragged, the "draging class" will only be added if its not.

I don't think i ever taught of nestled elements and I might have overdone that parent function, pretty sure theres a more simple way to do it.

fisshy avatar Jan 28 '14 20:01 fisshy

Ok so that's what I thought, but when I try to look for a smaller case it never matches... I think you'd need id's or something as the two sides don't ever equal out even though on inspection they are the same.

Sent from my iPhone

On Jan 28, 2014, at 3:51 PM, Joachim [email protected] wrote:

What I wanted to solve was so you couldn't drop the element back at owner because then it would copy itself.

So what it does is to check if the parent is the same of the item thats being dragged, the "draging class" will only be added if its not.

I don't think i ever taught of nestled elements and I might have overdone that parent function, pretty sure theres a more simple way to do it.

— Reply to this email directly or view it on GitHub.

apinstein avatar Jan 28 '14 21:01 apinstein

You're probably right. If you find any solution feel free to make a PR. Might look into it in the weekend otherwise or maybe I will solve it before, got kinda much going on atm :)

fisshy avatar Jan 28 '14 21:01 fisshy

Yeah I'm in the same boat. I got it working for me for now so no rush.

Sent from my iPhone

On Jan 28, 2014, at 4:30 PM, Joachim [email protected] wrote:

You're probably right. If you find any solution feel free to make a PR. Might look into it in the weekend otherwise or maybe I will solve it before, got kinda much going on atm :)

— Reply to this email directly or view it on GitHub.

apinstein avatar Jan 28 '14 22:01 apinstein

I'm having a similar problem.

boxxxie avatar Jul 10 '14 13:07 boxxxie