<script>
import Moveable from "vue-moveable";

export default {
    components: { Moveable },
    data() {
        const rotatable = "$preview_rotatable";
        const throttleRotate = "$preview_throttleRotate";
        const rotationPosition = "$preview_rotationPosition";
        const targetRef = null;
        return { rotatable, throttleRotate, rotationPosition, targetRef };
    },
    methods: { onRotate(e) {
        e.target.style.transform = e.drag.transform;
    } },
    mounted() {
        this.targetRef = this.$refs.targetRef;
    }
};
</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>