Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngxDraggable inside component dosen't emit value #107

Open
bartosz-brodzik opened this issue Jul 13, 2018 · 2 comments
Open

ngxDraggable inside component dosen't emit value #107

bartosz-brodzik opened this issue Jul 13, 2018 · 2 comments

Comments

@bartosz-brodzik
Copy link

bartosz-brodzik commented Jul 13, 2018

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Sorry, we will not be able to answer every support request.  Please consider other venues for support requests

Current behavior
For most simple use case.

<div ngxDroppable (drop)="dropped($event)" >
  <custom-component1>
  <custom-component2>
</div>
custom-component1 template: <div ngxDraggable [model]="{name: 'custom1}">custom-1</div>
custom-component2 template: <div ngxDraggable [model]="{name: 'custom2}">custom-2</div>

While dropped, custom component will not emit any value. I can't just wrap my two components with div and attach ngxDraggable to that div because my custom components are created dynamically. After some digging in your code I found that the problem is in this line:
this.drake.on('drag'....) {
...
if (_this.draggableMap.has(el))
...
}

Because el is custom-component1 and draggableMap expects it to be the div inside it.

Expected behavior
Be able to attach ngxDaggable inside custom component and still take advantage of [model] functionality. It's quite important in my use case so it would be great If some could look into that :).

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-dnd version: 5.0.6
  • Angular version: 6.0.7
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]
@Hypercubed
Copy link
Contributor

Can you create a demo that reproduces this issue?

@lokopak
Copy link

lokopak commented Aug 8, 2018

Try this:

In your

<div ngxDroppable (drop)="dropped($event)" >
<custom-component1  ngxDraggable [model]="{name: 'custom1}"></custom-component1>
<custom-component2   ngxDraggable [model]="{name: 'custom2}"></custom-component2>
</div>

In your templates:

custom-component1 template: <div>custom-1</div>
custom-component2 template: <div>custom-2</div>

In your custom components add:
@Input() model: any;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants