I am developing a single-page application using Vue.js. The user interface consists of three main components:
- A fixed navbar at the top with a z-index of 2
- A fixed sidebar on the left with a z-index of 1, and padding to accommodate the navbar
- A central area with padding to account for the other fixed elements.
The sidebar is scrollable with overflow-y: auto. Certain items within the sidebar, referred to as "item X" here, are draggable.
Typically, when moving towards the edges of a scrollable area while dragging, the area will automatically scroll in that direction. However, in my app, the sidebar does not autoscroll because its upper edge is covered by the navbar.
One solution could involve restructuring the sidebar so that its upper edge is visible instead of being hidden beneath a padded div. However, this approach may have unintended consequences.
Question: I would like to explore methods for triggering auto-scroll during drag when the mouse is close to the edge, perhaps within $navbarHeight pixels.
I am seeking a solution that is pure HTML5, vanilla JavaScript, or compatible with my current framework (Vue.js v3).
What I have attempted: Despite extensive research, keywords such as "auto scroll while dragging," "scroll sensitivity area," and "autoscroll offset" have not provided relevant insights.
JS Fiddle: https://jsfiddle.net/7f5wh1mj/4/
Visual Representation: Please refer to the fiddle for a live demonstration.