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

export default {
    components: { Moveable },
    setup() {
        const keepRatio = "$preview_keepRatio";
        const throttleScale = "$preview_throttleScale";
        const renderDirections = "$preview_renderDirections";
        const targetRef = ref(null);
        const onScale = e => {
            e.target.style.transform = e.drag.transform;
        };
        return {
            targetRef,
            keepRatio,
            throttleScale,
            renderDirections,
            onScale
        };
    }
};
</script>
<template>
    <div class="root">
        <div class="container">
            <div
                class="target"
                ref="targetRef"
            >Target</div>
            <Moveable
                :target="targetRef"
                :scalable="true"
                :keepRatio="keepRatio"
                :throttleScale="throttleScale"
                :renderDirections="renderDirections"
                @scale="onScale"/>
        </div>
    </div>
</template>