<script>
import Moveable from "vue3-moveable";
import { ref, onMounted } from "vue";

export default {
    components: { Moveable },
    setup() {
        const targets = ref(".target");
        const onDragGroup = ({ events }) => {
            events.forEach(ev => {
                ev.target.style.transform = ev.transform;
            });
        };
        const onDragGroupEnd = ({ events }) => {
            console.log(events);
        };
        onMounted(() => {
            setTimeout(() => {
                targets.value = document.querySelectorAll(".target, .moveable-area");
            }, 100);
        });
        return { targets, 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="targets"
            :draggable="true"
            @dragGroup="onDragGroup"
            @dragGroupEnd="onDragGroupEnd"/>
    </div>
</template>