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

export default {
    components: { Moveable },
    setup() {
        const hideChildMoveableDefaultLines = "$preview_hideChildMoveableDefaultLines";
        const draggable = "$preview_draggable";
        const throttleDrag = "$preview_throttleDrag";
        const edgeDraggable = "$preview_edgeDraggable";
        const startDragRotate = "$preview_startDragRotate";
        const throttleDragRotate = "$preview_throttleDragRotate";
        const scalable = "$preview_scalable";
        const keepRatio = "$preview_keepRatio";
        const throttleScale = "$preview_throttleScale";
        const renderDirections = "$preview_renderDirections";
        const rotatable = "$preview_rotatable";
        const throttleRotate = "$preview_throttleRotate";
        const rotationPosition = "$preview_rotationPosition";
        const onDragGroup = ({ events }) => {
            events.forEach(ev => {
                ev.target.style.transform = ev.transform;
            });
        };
        const onScaleGroup = ({ events }) => {
            events.forEach(ev => {
                ev.target.style.transform = ev.drag.transform;
            });
        };
        const onRotateGroup = ({ events }) => {
            events.forEach(ev => {
                ev.target.style.transform = ev.drag.transform;
            });
        };
        return {
            hideChildMoveableDefaultLines,
            draggable,
            throttleDrag,
            edgeDraggable,
            startDragRotate,
            throttleDragRotate,
            scalable,
            keepRatio,
            throttleScale,
            renderDirections,
            rotatable,
            throttleRotate,
            rotationPosition,
            onDragGroup,
            onScaleGroup,
            onRotateGroup
        };
    }
};
</script>
<template>
    <div class="container">
        <div class="target target1">Target1</div>
        <div class="target target2">Target2</div>
        <div
            class="target target3"
            style="transform: scale(1, -1);"
        >Target3</div>
        <Moveable
            :target="'.target'"
            :hideChildMoveableDefaultLines="hideChildMoveableDefaultLines"
            :draggable="draggable"
            :throttleDrag="throttleDrag"
            :edgeDraggable="edgeDraggable"
            :startDragRotate="startDragRotate"
            :throttleDragRotate="throttleDragRotate"
            :scalable="scalable"
            :keepRatio="keepRatio"
            :throttleScale="throttleScale"
            :renderDirections="renderDirections"
            :rotatable="rotatable"
            :throttleRotate="throttleRotate"
            :rotationPosition="rotationPosition"
            @dragGroup="onDragGroup"
            @scaleGroup="onScaleGroup"
            @rotateGroup="onRotateGroup"/>
    </div>
</template>