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

export default {
    components: { Moveable },
    setup() {
        const targetRef = ref(null);
        const onDrag = e => {
            e.target.style.transform = e.transform;
        };
        const onDragOrigin = e => {
            e.target.style.transformOrigin = e.transformOrigin;
            e.target.style.transform = e.drag.transform;
        };
        const onRotate = e => {
            e.target.style.transform = e.drag.transform;
        };
        return { targetRef, onDrag, onDragOrigin, onRotate };
    }
};
</script>
<template>
    <div class="root">
        <div class="container">
            <div
                class="target"
                ref="targetRef"
            >Target</div>
            <Moveable
                :target="targetRef"
                :originDraggable="true"
                :draggable="true"
                :rotatable="true"
                @drag="onDrag"
                @dragOrigin="onDragOrigin"
                @rotate="onRotate"/>
        </div>
    </div>
</template>