moveable icon indicating copy to clipboard operation
moveable copied to clipboard

Rotatable: setting the center of rotation

Open miina opened this issue 3 years ago • 3 comments

Environments

  • Framework name: React
  • Framework version: 17.0.2
  • Moveable Component version: 0.34
  • Testable Address(optional):

Description

Is it possible to change the center of the rotation? For example if instead of rotating around the center of the target, I'd like to rotate the element around a point [x, y] within the element?

miina avatar Jul 22 '22 13:07 miina

@miina

you can use setFixedDirection on rotateStart

https://daybrush.com/moveable/storybook2/?path=/story/advanced-rotatable--rotate-with-custom-origin

daybrush avatar Jul 22 '22 14:07 daybrush

@miina

you can use setFixedDirection on rotateStart

https://daybrush.com/moveable/storybook2/?path=/story/advanced-rotatable--rotate-with-custom-origin

Ah, thank you, I saw the storybook in the code for it but didn't find the story for some reason, wasn't sure it was for that. Does setFixedDirection use pixels as unit? Or looking at the code perhaps values from -1 to 1 where [0, 0] is the center, [-1, -1] is the left top?

miina avatar Jul 22 '22 15:07 miina

@miina

Since it is a direction, it is determined according to the direction and is relative to offsetWidth and offsetHeight.

[0, 0] is center [-1, -1] left, top [1, -1] right top [-1, 1] left bottom [1, 1,] right bottom

daybrush avatar Jul 22 '22 15:07 daybrush

@daybrush

Since it is a direction, it is determined according to the direction and is relative to offsetWidth and offsetHeight.

[0, 0] is center [-1, -1] left, top [1, -1] right top [-1, 1] right bottom [1, 1,] right bottom

[-1, 1] right bottom is it suppose to be left bottom?

ngocducdim avatar May 29 '23 05:05 ngocducdim

@ngocducdim

right. my typo

daybrush avatar May 31 '23 17:05 daybrush