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

export default {
    components: { Moveable },
    setup() {
        const draggable = "$preview_draggable";
        const throttleDrag = "$preview_throttleDrag";
        const edgeDraggable = "$preview_edgeDraggable";
        const startDragRotate = "$preview_startDragRotate";
        const throttleDragRotate = "$preview_throttleDragRotate";
        const resizable = "$preview_resizable";
        const keepRatio = "$preview_keepRatio";
        const edge = "$preview_edge";
        const onRenderGroup = e => {
            e.events.forEach(ev => {
                ev.target.style.cssText += ev.cssText;
            });
        };
        return {
            draggable,
            throttleDrag,
            edgeDraggable,
            startDragRotate,
            throttleDragRotate,
            resizable,
            keepRatio,
            edge,
            onRenderGroup
        };
    }
};
</script>
<template>
    <div class="root">
        <div
            class="container"
            style="width: 500px;height: 500px;border: 1px solid #ccc;"
        >
            <div
                class="target target1"
                style="top: 100px;left: 100px;"
            >Target1</div>
            <div
                class="target target2"
                style="top: 150px;left: 150px;"
            >Target2</div>
            <div
                class="target target3"
                style="top: 200px;left: 200px;"
            >Target3</div>
            <Moveable
                :target="'.target'"
                :draggable="draggable"
                :throttleDrag="throttleDrag"
                :edgeDraggable="edgeDraggable"
                :startDragRotate="startDragRotate"
                :throttleDragRotate="throttleDragRotate"
                :resizable="resizable"
                :keepRatio="keepRatio"
                :edge="edge"
                :snappable="true"
                :snapGridWidth="50"
                :snapGridHeight="50"
                :snapThreshold="50"
                :snapGridAll="true"
                :isDisplayGridGuidelines="true"
                @renderGroup="onRenderGroup"/>
        </div>
    </div>
</template>