Moveable: snap option

Created on 4 Aug 2019  路  4Comments  路  Source: daybrush/moveable

Are you planning to add the snap option?
For example, while holding down the shift key, it is easy to adjust the rotation to 0, 90, 180 and 270 degrees.

Feature complete question solved

All 4 comments

@comiewcom
Hi ~ :)
You probably mean throttleRotate.

Use as follows.
```jsx
throttleRotate={isShift ? 90 : 0}
/>

Is it possible to apply a snap only when approaching 0, 90, 180, or 270 degrees?
Thank you for the wonderful project.

@comiewcom
Thank you :)

Unfortunately, I don't know your angle, so I have to do it manually now.

<Moveable
     onRotate={({ beforeDelta }) => {
        this.rotation += beforeDelta;
        const rotation = Math.floor(this.rotation / 90) * 90;

        console.log(rotation);
    }}
/>

Instead, the function of the issue will replace it.
https://github.com/daybrush/moveable/issues/6

@comiewcom

Moveable 0.8.0 is released!!!

You can use set methods and beforeRotate for absolute value.

let rotation = 10;

<Moveable
     throttleRotate={90}
     onRotateStart={({ set }) => {
         set(rotation);
     }}
     onRotate={({ beforeRotate }) => {
         console.log(beforeRotate);
         rotation = beforeRotate;
     }}
/>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

pistell picture pistell  路  4Comments

prasanthLalapeta picture prasanthLalapeta  路  4Comments

jiseopX picture jiseopX  路  4Comments

ajinkya-dev picture ajinkya-dev  路  3Comments

probil picture probil  路  4Comments