<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;
        },
        onResize(e) {
            e.target.style.width = `${e.width}px`;
            e.target.style.height = `${e.height}px`;
            e.target.style.transform = e.drag.transform;
        },
        onClip(e) {
            e.target.style.clipPath = e.clipStyle;
        }
    },
    mounted() {
        this.targetRef = this.$refs.targetRef;
    }
};
</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>