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

export default {
    components: { Moveable },
    setup() {
        const moveableRef = ref(null);
        const onScroll = () => {
            moveableRef.value?.updateRect();
        };
        const onDrag = e => {
            e.target.style.transform = e.transform;
        };
        return { onScroll, moveableRef, onDrag };
    }
};
</script>
<template>
    <div class="root">
        <div
            class="container"
            style="height: 100px;"
        >
            <div
                class="target"
                style="overflow: auto;"
                @scroll="onScroll"
            >
                <div
                    class="scroll"
                    style="width: 100%;height: 1000px;"
                ></div>
            </div>
            <Moveable
                ref="moveableRef"
                :target="'.target'"
                :resizable="true"
                :preventClickDefault="true"
                :draggable="true"
                @drag="onDrag"/>
        </div>
    </div>
</template>