anseki / plain-draggable

The simple and high performance library to allow HTML/SVG element to be dragged.
https://anseki.github.io/plain-draggable/
MIT License
773 stars 99 forks source link

Re-Drag after update item size #61

Closed kaysaith1900 closed 4 years ago

kaysaith1900 commented 4 years ago

Hey anseki:

  1. there is an element that I will dynamic update its size by a button.
  2. after I updated the element size and used draggable.position() to update containment area , I drag it in first time everything is find, but I drag it in second time its size changed back again.

this is an example, have a look. thanks a lot. https://jsfiddle.net/cs61wh0u/1/

anseki commented 4 years ago

Hi @kaysaith1900, thank you for the comment. Try this: https://jsfiddle.net/c63nwm2k/

kaysaith1900 commented 4 years ago

Hi @anseki : try this example, https://jsfiddle.net/bftm6jh2/3/

  1. move the default element to random position
  2. update the element size bigger than parent
  3. i can't move in a correct path.

thanks a lot for helping me solve this problem. : )

anseki commented 4 years ago

Do you mean that you can't move the element horizontally after that was resized? If so, that is correct behavior. See document: https://anseki.github.io/plain-draggable/#options-containment

kaysaith1900 commented 4 years ago

@anseki , thanks a lot for replying, i got it . i will update the parent(contaiment) size once the child element size is bigger than parent. : )

anseki commented 4 years ago

:smile:

kaysaith1900 commented 4 years ago

Hi @anseki , new problem for helping, this is your example below, the element size will change back again when I resize the window. you can try that in your example. thanks a lot .

Hi @kaysaith1900, thank you for the comment. Try this: https://jsfiddle.net/c63nwm2k/

anseki commented 4 years ago

Try this: https://jsfiddle.net/xbwu257d/

kaysaith1900 commented 4 years ago

thanks @anseki , it works. but I hope I can handle style by javascript style, not depends css to do this. hope you can provide a method to do this. : ) love this library.

anseki commented 4 years ago

Do you mean that you don't want to use classes?

kaysaith1900 commented 4 years ago

yes, I wanna dynamic update the element style by user enter input value. it is not convenient using class to do this.

anseki commented 4 years ago

Try this: https://jsfiddle.net/n2rhLy0u/

kaysaith1900 commented 4 years ago

cool, smart way to solve it. Although I have one more div, I still love it. thanks @anseki . 👍

anseki commented 4 years ago

:smile: