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

export default {
    components: { Moveable },
    data() {
        const containerScale = "$preview_containerScale";
        return { containerScale };
    },
    methods: { onRender(e) {
        e.target.style.cssText += e.cssText;
    } }
};
</script>
<template>
    <div class="root">
        <div
            class="container"
            :style="`transform-origin: 0 0;transform: ${`scale(${containerScale})`};`"
        >
            <svg
                viewBox="0 0 200 200"
                style="border: 1px solid black;width: 200px;height: 200px;"
            >
                <path
                    d="M 0 0 L 200 0 L 200 200 z"
                    style="fill: white;stroke: red;stroke-width: 2;"/>
            </svg>
            <Moveable
                :target="'path'"
                :draggable="true"
                :rotatable="true"
                :scalable="true"
                svgOrigin="50% 50%"
                @render="onRender"/>
        </div>
    </div>
</template>