react-avatar-editor icon indicating copy to clipboard operation
react-avatar-editor copied to clipboard

Can rotation be animated?

Open gaohomway opened this issue 2 years ago • 3 comments

Can rotation be animated?

gaohomway avatar Apr 24 '22 03:04 gaohomway

Can rotation be animated?

It should be easy to animate it, just rotate it slowly in an X amount of time

pwnedev avatar May 16 '22 16:05 pwnedev

@pwnedev Can you give the specific implementation code?

gaohomway avatar May 16 '22 16:05 gaohomway

I tried to complete the rotation animation

    let id = null
    function rotateAnimation(plus) {
        let pos = rotate
        clearInterval(id)
        id = setInterval(frame, 0)
        function frame() {
            if (pos === rotate + (plus ? -90 : 90) ) {
                clearInterval(id)
                setRotate(pos % 360)
            } else {
                plus ? pos-- : pos++
                setRotate(pos)
            }
        }
    }


gaohomway avatar May 23 '22 08:05 gaohomway