Closed g40 closed 1 year ago
Hi @g40, thank you for the comment.
It seems that you mistook left
/ top
CSS properties for the left
/ top
attributes. PlainDraggable never changes attribute, and it never changes the left
/ top
CSS properties unless leftTop
option of constructor is specified.
If you want to change the position of the draggable element manually, you can use left
/ top
options or properties of PlainDraggable. If you change both left
and top
, the options are better than properties.
@anseki Thank you.
Yes - please ignore the left/top attributes. Those are for setting the initial position only - that BTW should be one of the options passed to the PlainDraggable
constructor.
I am not enabling the leftTop
option so is it best to simply modify the transform translate
values?
The left
/ top
attributes should not be passed to the constructor because those don't exist. And also, PlainDraggable should not move the element via those because it has already left
/ top
options.
The changing transform
CSS property is not good way. That may break the library. The way that I recommended is best way because the library was designed with that. In other words, the library doesn't consider your way.
BTW, I can't understand the "multiple elements as a group" that you said. Do the multiple elements move synchronously by dragging one of those?
Ignore the left/top attributes. These are for my code to locate elements in a div. So that leaves 2 questions: 1) How to specify the initial position of the newly added element? 2) How to move 2 or more element synchronously by dragging one of them?
Ignore the left/top attributes. These are for my code to locate elements in a div. So that leaves 2 questions:
- How to specify the initial position of the newly added element?
You don't have to specify that to PlainDraggable because PlainDraggable never changes the position unless the element is dragged. That is, the element is only rendered via your HTML and CSS code. You can position the element by using your favorite way.
- How to move 2 or more element synchronously by dragging one of them?
This may help you: https://jsfiddle.net/513r7asp/ If you answer the my question, I can understand more that.
No reply came, then this abandoned issue is closed.
Anyway, if you want to change the position of the draggable element manually, the best way to that is the left
/ top
options, as I have repeatedly said since the my first comment.
https://github.com/anseki/plain-draggable/issues/135#issuecomment-1528647481
By inspection one can see that a drag is achieved by modifying the transform attribute of the element in question. In this case, the top/left attributes are used only when adding the element dynamically to a layout.
To move multiple elements as a group, is it best to simply adjust the transform values to suit? Or is there a safer API available?