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

Wrong position after window resize in case of using CSS scale #125

Closed catybar closed 1 year ago

catybar commented 1 year ago

Hello, thank you for implementing and supporting such a great project!

Here another issue relates to problem with CSS scale, and in this comment https://github.com/anseki/plain-draggable/issues/13#issuecomment-449687383 you provided a fiddle https://jsfiddle.net/5rzkxpaf/. I use this fiddle to reproduce problem i'm talking about.

Take a look at the gif - after window's resize the red square start moving to right-bottom direction and then it even disappears. Note, to reproduce it firstly you need to move the square from it's initial position.

Could you please advise some workaround to overcome this problem?

ezgif com-gif-maker

anseki commented 1 year ago

Hi @catybar, thank you for the comment. Best advice for you is that avoid using the scale property because that is not good way to change the size as I said in the past issue. That should be moved regardless of resizing window and scrolling and others because position is lost when the mouse pointer is released once. The scale changes only the transformation without changing view. You had better use e.g. SVG that has viewBox to allows to really change scale of the view.

catybar commented 1 year ago

Ok, got it, thank you!

anseki commented 1 year ago

:smile: