import { type Ref } from "vue"; import type { ScrollNearContainerEdgesOptions } from "../types.js"; /** * Creates a function `scrollContainer` that allows scrolling a container manually when the coordinates are near it's edges. * Supports scrolling faster the closer one is to the edge, and configuing an inner and outer margin. * * It can be used in any *move event. * * By default it sets a setInterval timer to continue scrolling even when the user does not move. * An `endScroll` function is provided which should be called on the *up event to cleanup the timer and variables properly (there is also the individual `clearScrollInterval` and `resetCanScroll` functions. * * It also provides an `isScrolling` ref and a `scrollIndicator` reactive object for knowing which direction the user is scrolling in to be able to style the element. They can be force cleared with the `resetCanScroll` function. * * ```ts * const { * scrollEdges, * isScrolling, * scrollIndicator, * endScroll, * } = useScrollNearContainerEdges({ * containerEl, * scrollMargin, * outerScrollMargin, * }) * * const onPointerMove = (e: PointerEvent): void => { * scrollEdges(e.clientX, e.clientY) * if (isScrolling.value) { * e.preventDefault() * return * } * //... * } * const onPointerUp = (_e: PointerEvent): void => { * endScroll() * //... * } * ``` * Styling example with tailwind and tailwind-merge: * * ```vue *