<script>
import Moveable from "vue3-moveable";
import { ref } from "vue";

export default {
    components: { Moveable },
    setup() {
        const rotatable = "$preview_rotatable";
        const throttleRotate = "$preview_throttleRotate";
        const rotationPosition = "$preview_rotationPosition";
        const targetRef = ref(null);
        const onRotate = e => {
            e.target.style.transform = e.drag.transform;
        };
        return {
            targetRef,
            rotatable,
            throttleRotate,
            rotationPosition,
            onRotate
        };
    }
};
</script>
<template>
    <div class="root">
        <div class="container">
            <div
                class="target"
                ref="targetRef"
                style="transform: translate(0px, 0px) rotate(0deg);"
            >Target</div>
            <Moveable
                :target="targetRef"
                :rotatable="rotatable"
                :throttleRotate="throttleRotate"
                :rotationPosition="rotationPosition"
                @rotate="onRotate"/>
        </div>
    </div>
</template>