daybrush / moveable

Moveable! Draggable! Resizable! Scalable! Rotatable! Warpable! Pinchable! Groupable! Snappable!
https://daybrush.com/moveable/
MIT License
9.84k stars 606 forks source link

[question] - Is there any way to get/set a relative position? #297

Open antonreshetov opened 3 years ago

antonreshetov commented 3 years ago

Environments

Description

First, I want to say thank you for the awesome library! I'm interested in the question, is there any way to get/set a relative position?

daybrush commented 3 years ago

@antonreshetov What does relative position mean?

antonreshetov commented 3 years ago

As a percentage of the container. left: 10%; top: 10%

daybrush commented 3 years ago

@antonreshetov

It still only gives a value in px. I'm sorry.


left = `${e.left / e.target.offsetWidth * 100}%`;
top = `${e.top / e.target.offsetHeight * 100}%`;
antonreshetov commented 3 years ago

@daybrush thanks, I think this is the way out. Math isn't my thing 😂

daybrush commented 3 years ago

@antonreshetov okay. I'll add relative propery next release.