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

export default {
    components: { Moveable },
    data() {
        const edge = "$preview_edge";
        const keepRatio = "$preview_keepRatio";
        const innerBounds = "$preview_innerBounds";
        return { edge, keepRatio, innerBounds };
    },
    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;
        },
        onBound(e) {
            console.log(e);
        }
    }
};
</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>