<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.cssText += e.cssText;
            this.$refs.targetRef.innerText = e.transform;
        },
        onScale(e) {
            e.target.style.cssText += e.cssText;
            this.$refs.targetRef.innerText = e.cssText;
        }
    },
    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: 700px;height: 700px;"
    >
        <div
            ref="containerRef"
            class="container2"
            style="width: 499px;height: 499px;outline: 1px solid #ccc;"
        >
            <div
                class="target2"
                ref="targetRef"
                style="width: 200px;height: 200px;"
            >Target</div>
            <Moveable
                ref="moveableRef"
                :target="targetRef"
                :draggable="true"
                :scalable="true"
                :edgeDraggable="false"
                :startDragRotate="0"
                :throttleDragRotate="0"
                :keepRatio="false"
                :throttleScale="0"
                :snappable="true"
                :elementGuidelines="[containerRef]"
                :horizontalGuidelines="[150]"
                :verticalGuidelines="[220]"
                @drag="onDrag"
                @scale="onScale"/>
        </div>
    </div>
</template>