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

export default {
    components: { Moveable },
    data() {
        const targetRef = null;
        return { targetRef };
    },
    methods: {
        onDrag(e) {
            e.target.style.transform = e.transform;
        },
        onDragOrigin(e) {
            e.target.style.transformOrigin = e.transformOrigin;
            e.target.style.transform = e.drag.transform;
        },
        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"
            >Target</div>
            <Moveable
                :target="targetRef"
                :originDraggable="true"
                :draggable="true"
                :rotatable="true"
                @drag="onDrag"
                @dragOrigin="onDragOrigin"
                @rotate="onRotate"/>
        </div>
    </div>
</template>