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

export default {
    components: { Moveable },
    setup() {
        const draggable = "$preview_draggable";
        const startDragRotate = "$preview_startDragRotate";
        const throttleDragRotate = "$preview_throttleDragRotate";
        const zoom = "$preview_zoom";
        const clippable = "$preview_clippable";
        const clipRelative = "$preview_clipRelative";
        const clipArea = "$preview_clipArea";
        const dragArea = "$preview_dragArea";
        const dragWithClip = "$preview_dragWithClip";
        const defaultClipPath = "$preview_defaultClipPath";
        const clipTargetBounds = "$preview_clipTargetBounds";
        const keepRatio = "$preview_keepRatio";
        const targetRef = ref(null);
        const onDrag = e => {
            e.target.style.transform = e.transform;
        };
        const onClip = e => {
            e.target.style.clipPath = e.clipStyle;
        };
        return {
            targetRef,
            draggable,
            startDragRotate,
            throttleDragRotate,
            zoom,
            clippable,
            clipRelative,
            clipArea,
            dragArea,
            dragWithClip,
            defaultClipPath,
            clipTargetBounds,
            keepRatio,
            onDrag,
            onClip
        };
    }
};
</script>
<template>
    <div class="root">
        <div class="container">
            <div
                class="target"
                ref="targetRef"
            >Target</div>
            <Moveable
                :target="targetRef"
                :draggable="draggable"
                :startDragRotate="startDragRotate"
                :throttleDragRotate="throttleDragRotate"
                :zoom="zoom"
                :clippable="clippable"
                :clipRelative="clipRelative"
                :clipArea="clipArea"
                :dragArea="dragArea"
                :dragWithClip="dragWithClip"
                :defaultClipPath="defaultClipPath"
                :clipTargetBounds="clipTargetBounds"
                :snapThreshold="5"
                :keepRatio="keepRatio"
                @drag="onDrag"
                @clip="onClip"/>
        </div>
    </div>
</template>