<script>
import Moveable, { DIRECTIONS } from "vue3-moveable";
import { useKeycon } from "vue-keycon";

export default {
    components: { Moveable },
    setup() {
        const { isKeydown } = useKeycon({ keys: ["meta"] });
        const onResize = e => {
            e.target.style.cssText += e.cssText;
        };
        const onRotateStart = e => {
            e.setFixedDirection([-0.5, -0.5]);
        };
        const onRotate = e => {
            e.target.style.cssText += e.cssText;
        };
        return { isKeydown, DIRECTIONS, onResize, onRotateStart, onRotate };
    }
};
</script>
<template>
    <div class="root">
        <div class="target">Target</div>
        <Moveable
            :target="'.target'"
            :rotatable="({ renderDirections: isKeydown.value ? DIRECTIONS : false })"
            :resizable="({ renderDirections: isKeydown.value ? false : true })"
            :rotateAroundControls="true"
            @resize="onResize"
            @rotateStart="onRotateStart"
            @rotate="onRotate"/>
    </div>
</template>