daybrush / moveable

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

round rotate near 90 multiple degrees angles #928

Open Nonoizz opened 1 year ago

Nonoizz commented 1 year ago

Environments

Description

When using rotate, i would like the 90 degrees angle (0, 90, 180, 270) to be blocked when the value is close. For example

It only rounds when the value is close of 0, 90, 180, 270

check this for inspiration: rotation

What's the best solution to achieve this kind of behavior ?

Thanks for reading

daybrush commented 1 year ago

@Nonoizz

Sounds like a good idea.

I'll add it in the next update.

jadiagaurang commented 1 year ago

@Nonoizz @daybrush

Yes, This is a very good idea. I am also looking forward to add to improve UX.

Possible config:

snapRotation: true,
snapRotationThreshold: 1,   // +/- 1 deg
snapRotationDegrees: [
  0,
  90,
  180,
  270
]
daybrush commented 1 year ago

@jadiagaurang @Nonoizz

moveable's new version is released. snapRotationThreshold (default: 5), snapRotationDegrees (default: []) props are added

See this example: https://daybrush.com/moveable/storybook/?path=/story/snap-bound--snap-rotations

Nonoizz commented 1 year ago

Amazing! nice job!

jadiagaurang commented 1 year ago

@daybrush

I tried this new config. It worked very well. Thanks again!

davidalejandroaguilar commented 1 year ago

@daybrush You accidentally named this snapRotationDegress instead of snapRotationDegrees, even though in the Storybook you shared its spelled correctly.

image
daybrush commented 1 year ago

@davidalejandroaguilar

Oh sorry, I'll fix it in the next version.

daybrush commented 1 year ago

@jadiagaurang @Nonoizz @davidalejandroaguilar

moveable's new version is released.

Change prop name snapRotationDegress to snapRotationDegrees. Check it again.