<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 onResize = e => {
            e.target.style.width = `${e.width}px`;
            e.target.style.height = `${e.height}px`;
            e.target.style.transform = e.drag.transform;
        };
        const onClip = e => {
            e.target.style.clipPath = e.clipStyle;
        };
        return { targetRef, onDrag, onResize, onClip };
    }
};
</script>
<template>
    <div class="root">
        <div class="container">
            <div
                class="target"
                ref="targetRef"
                style="top: 50px;left: 50px;width: 200px;height: 200px;"
            >Target</div>
            <Moveable
                :target="targetRef"
                :draggable="true"
                :resizable="true"
                :clippable="true"
                :dragWithClip="false"
                :clipTargetBounds="true"
                :snappable="true"
                :horizontalGuidelines="[0, 100, 200, 300]"
                :snapThreshold="5"
                @drag="onDrag"
                @resize="onResize"
                @clip="onClip"/>
        </div>
    </div>
</template>