Tiny Drag/Swipe To Scroll Plugin For jQuery - Dragscrollable

File Size: 6.52 KB
Views Total: 651
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Tiny Drag/Swipe To Scroll Plugin For jQuery - Dragscrollable

Dragscrollable is a tiny jQuery plugin that enables Drag To Scroll (desktop) and Swipe To Scroll (mobile & tablet) functionalities on scrollable elements.

It is useful when containing extra-wide or tall elements (such as hi-res images) in a small container so that the user can view the full content with mouse drag or finger swipe.

See Also:

How to use it:

1. Download and place the JavaScript file dragscrollable.min.js after jQuery library.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/dragscrollable.min.js"></script>

2. Call the function dragscrollable on your scrollable container and the plugin will do the rest.

<div class="box">
  <img src="xs.jpg" />
/* make it scrollable */
.box { 
  width: 400px; 
  height: 300px; 
  overflow: scroll; 
  // options here

3. By default, the plugin automatically enables the drag (swipe) to scroll functionality on the first child of the scrollable element. You can change the scrollable element by overriding the dragSelector option as follows.

  dragSelector: '>:first',

4. Determine whether the draggable element should accept propagated events. Default: true.

  acceptPropagatedEvent: false,

5. Determine whether to prevent the default behavior. Default: true.

  preventDefault: false,

6. Determine whether to enable horizontal scrolling. Default: true.

  allowY: true

7. Determine which mouse button should trigger the drag (swipe) to scroll functionality. Default: 1 (left button).

  // middle button
  which: 2,

  // right button
  which: 3,

This awesome jQuery plugin is developed by mvlandys. For more Advanced Usages, please check the demo page or visit the official website.