ScrollManager
Monitors the mouse position over an element and scrolls the element if the cursor is close to edges. This is used by various features to scroll the grid section element, for example dragging elements close to edges.
// Instantiate manager for the container element having overflowing content
const manager = new ScrollManager({ element : document.querySelector('.container') });
// Start monitoring. When pointer approaches 50px region within monitored element edge, scrolling begins
manager.startMonitoring();
// Stop monitoring.
manager.stopMonitoring();
Useful configs and functions
| Config / Function | Description |
|---|---|
| element | Element to monitor for edge proximity |
| zoneWidth | Width in pixels of the scroll trigger zone |
| scrollSpeed | Scroll speed divisor (higher = slower) |
| startMonitoring | Begin monitoring pointer position |
| stopMonitoring | Stop monitoring and scrolling |
See also
- DragHelper - Drag-and-drop helper that uses ScrollManager
- DomHelper - DOM element utilities
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
The direction(s) to scroll ('horizontal', 'vertical' or 'both')
-
Default element to use for scrolling. Can be overridden in calls to
startMonitoring(). -
Scroll speed, higher number is slower. Calculated as "distance from zone edge / scrollSpeed"
-
Number of milliseconds to wait before scroll starts when the mouse is moved close to an edge monitored by this scroll manager
-
Set to
trueto stop scrolling when pointing device leaves the scrollable element. -
Width in pixels of the area at the edges of an element where scrolling should be triggered
Properties
Properties are getters/setters or publicly accessible variables on this class-
Returns true if some of the monitored elements is being scrolled at the moment.