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

export default {
    components: { Moveable },
    setup() {
        const edge = "$preview_edge";
        const keepRatio = "$preview_keepRatio";
        const innerBounds = "$preview_innerBounds";
        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 onBound = e => {
            console.log(e);
        };
        return { edge, keepRatio, innerBounds, onDrag, onResize, onBound };
    }
};
</script>
<template>
    <div class="root">
        <div
            class="container"
            style="width: 500px;height: 500px;border: 1px solid #ccc;"
        >
            <div class="target">Target</div>
            <Moveable
                :target="'.target'"
                :draggable="true"
                :resizable="true"
                :edge="edge"
                :keepRatio="keepRatio"
                :snappable="true"
                :innerBounds="innerBounds"
                @drag="onDrag"
                @resize="onResize"
                @bound="onBound"/>
        </div>
    </div>
</template>