angular2-draggable
angular2-draggable copied to clipboard
how to set 'position' value dynamically
this directive is awesome. i wanna know that how to set the position value dynamically. thanks
You can use the input position in the element. It says that it sets the initial position but it can actually control the current position.
An example is this
<div ngDraggable class="drag-block"[position]="{x: objectVar?.x, y:objectVar?.y}">
if i set the value, element moves twice
What do you mean it moves twice? Can you paste an example code to have a closer look?
oh it's solved.
this is active
this.position = P1;
but this is not active
this.position.x = P1.x; this.position.y = P1.y;
I recommend having x,y properties in your object and use them like in the example earlier. This made things much easier for me to manipulate the position of the objects I wanted precisely. I'm glad that it's solved
thanks. it's very helpful for me
hello
i have a problem with the position
if i add dynamically a new draggable element, the position of the old elements change(in my exemple the element 1 "pompe 1" move automatically to behind when i add a new element
and if i add 2 element with the same position e.g {x:0,y:0}, they dot not show in the same place
in the img the there are 3 element that's have the same position but they are placed in different places
ps: sorry for my bad english
Can you post your code? Because I try to recreate it and I can't. I tried creating 2 elements on the same place and they overlap normally. Maybe you have them as a grid? This is how it looks and it would make sense for not allowing more than 1 element in a specific position.