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

export default {
    components: { Moveable },
    setup() {
        const onClick = () => {
            const width = 50 + Math.floor(50 * Math.random());
            const height = 50 + Math.floor(50 * Math.random());
            document.querySelector(".target").style.cssText += `width: ${width}px;height: ${height}px`;
        };
        const onDrag = e => {
            e.target.style.transform = e.transform;
        };
        const onResize = e => {
            e.target.style.width = `${e.width}px`;
            e.target.style.height = `${e.height}px`;
            e.target.style.transform = e.drag.transform;
        };
        const onRotate = e => {
            e.target.style.transform = e.drag.transform;
        };
        return { onClick, onDrag, onResize, onRotate };
    }
};
</script>
<template>
    <div class="root">
        <div class="container">
            <button @click="onClick">Random Resize</button>
            <div class="target">Target1</div>
            <Moveable
                :target="'.target'"
                :draggable="true"
                :rotatable="true"
                :resizable="true"
                :useResizeObserver="true"
                @drag="onDrag"
                @resize="onResize"
                @rotate="onRotate"/>
        </div>
    </div>
</template>