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

export default {
    components: { Moveable },
    setup() {
        const threshold = "$preview_threshold";
        const checkScrollEvent = "$preview_checkScrollEvent";
        const throttleTime = "$preview_throttleTime";
        const onRender = e => {
            e.target.style.cssText += e.cssText;
        };
        const onScroll = ({ scrollContainer, direction }) => {
            scrollContainer.scrollBy(direction[0] * 10, direction[1] * 10);
        };
        return {
            threshold,
            checkScrollEvent,
            throttleTime,
            onRender,
            onScroll
        };
    }
};
</script>
<template>
    <div class="container">
        <div class="scrollArea">
            <div class="target">Target</div>
            <Moveable
                :scrollable="true"
                :scrollOptions="({ container: '.scrollArea', threshold: threshold, checkScrollEvent: checkScrollEvent, throttleTime: throttleTime })"
                :target="'.target'"
                :draggable="true"
                :resizable="true"
                :rotatable="true"
                @render="onRender"
                @scroll="onScroll"
            ></Moveable>
        </div>
    </div>
</template>