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

export default {
    components: { Moveable },
    data() {
        const containerRef = null;
        const targetRef = null;
        const moveableRef = null;
        return { containerRef, targetRef, moveableRef };
    },
    methods: {
        onDrag(e) {
            e.target.style.transform = e.transform;
            this.$refs.targetRef.innerText = e.transform;
        },
        onScale(e) {
            e.target.style.transform = e.drag.transform;
        }
    },
    mounted() {
        this.containerRef = this.$refs.containerRef;
        this.targetRef = this.$refs.targetRef;
        this.moveableRef = this.$refs.moveableRef;
    }
};
</script>
<template>
    <div
        class="root"
        style="display: flex;justify-content: center;align-items: center;width: 700.2px;height: 700.2px;"
    >
        <div
            ref="containerRef"
            class="container2"
            style="width: 299px;height: 299px;outline: 10px solid #ccc;"
        >
            <div
                class="target2"
                ref="targetRef"
                style="width: 100px;height: 100px;"
            >Target</div>
            <Moveable
                ref="moveableRef"
                :target="targetRef"
                :draggable="true"
                :edgeDraggable="false"
                :startDragRotate="0"
                :throttleDragRotate="0"
                :keepRatio="false"
                :throttleScale="0"
                :snappable="true"
                :snapDirections="({ top: true, left: true, bottom: true, right: true, center: true, middle: true })"
                :elementSnapDirections="({ middle: true, center: true, top: true, left: true, bottom: true, right: true })"
                :snapThreshold="5"
                :elementGuidelines="[containerRef]"
                @drag="onDrag"
                @scale="onScale"/>
        </div>
    </div>
</template>