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

export default {
    components: { Moveable },
    setup() {
        const onResizeGroupStart = ({ events }) => {
            events[0].setMin([50, 50]);
            events[1].setMin([60, 50]);
            events[2].setMin([50, 60]);
        };
        const onResizeGroup = ({ events }) => {
            events.forEach(ev => {
                ev.target.style.width = `${ev.width}px`;
                ev.target.style.height = `${ev.height}px`;
                ev.target.style.transform = ev.drag.transform;
            });
        };
        const onDragGroup = ({ events }) => {
            events.forEach(ev => {
                ev.target.style.transform = ev.transform;
            });
        };
        const onDragGroupEnd = ({ events }) => {
            console.log(events);
        };
        return {
            onResizeGroupStart,
            onResizeGroup,
            onDragGroup,
            onDragGroupEnd
        };
    }
};
</script>
<template>
    <div class="container">
        <div class="target target1">Target1</div>
        <div class="target target2">Target2</div>
        <div class="target target3">Target3</div>
        <Moveable
            :target="'.target'"
            :draggable="true"
            :resizable="true"
            @resizeGroupStart="onResizeGroupStart"
            @resizeGroup="onResizeGroup"
            @dragGroup="onDragGroup"
            @dragGroupEnd="onDragGroupEnd"/>
    </div>
</template>