ESL Drag to Scroll

ESL Drag To Scroll Mixin

ESLDragToScrollMixin (esl-drag-to-scroll) is a custom attribute that enables drag-to-scroll functionality for any scrollable container element. This mixin enhances user experience by allowing intuitive drag-based scrolling, making it easier to navigate through content.

Configuration

The mixin uses a primary attribute, esl-drag-to-scroll, with optional configuration passed as a JSON attribute value.

Configuration options:

Default Configuration" The default configuration for the mixin is as follows:

{
    "axis": "both",
    "cls": "dragging",
    "tolerance": 10,
    "selection": true
}

Usage

To use the mixin, apply the esl-drag-to-scroll attribute to your scrollable container element.

<div class="esl-scrollable-content" esl-drag-to-scroll>
  <!-- Content here -->
</div>

You can also provide custom configuration through the JSON attribute. For example, to enable horizontal scrolling only, disable text selection, and use a custom class is-dragging during the drag.

<div class="esl-scrollable-content" esl-drag-to-scroll="{axis: 'x', cls: 'is-dragging', selection: false}">
  <!-- Content here -->
</div>