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

export default {
    components: { Moveable },
    setup() {
        const containerRef = ref(null);
        const targetRef = ref(null);
        const moveableRef = ref(null);
        const onDrag = (e) => {
            e.target.style.cssText += e.cssText;
            targetRef.value.innerText = e.transform;
        };
        const onScale = (e) => {
            e.target.style.cssText += e.cssText;
            targetRef.value.innerText = e.cssText;
        };
        return { containerRef, targetRef, moveableRef, onDrag, onScale };
    }
};
</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>