Click/tap and drag to scroll content within a container. Apply Dragit to a single container or every container on your page. Dragit is a small and simple plugin to use however you need.
With NPM:
npm install dragit --save
Or include Dragit directly:
<script src="/path/to/dragit.js"></script>
Dragit is written using ES2015 modules. To import Dragit into an ES2015 application:
import Dragit from 'dragit';
Dragit only requires a container element. All needed styles can be added during initialization of Dragit or with a seperate stylesheet.
<div id="dragme">
...
</div>
Apply Dragit to selected element(s) (all options with default values are shown).
const el = document.getElementById('dragme');
const dragme = new Dragit(el, {
addCursor: true,
dragX: true,
dragY: true,
addOverflow: true,
height: null,
width: null,
});
Type: Boolean
Default: true
Usage: Should Dragit add a grab and grabbing cursor style.
Type: Boolean
Default: true
Usage: Should Dragit allow for dragging on the X axis.
Type: Boolean
Default: true
Usage: Should Dragit allow for dragging on the Y axis.
Type: Boolean
Default: true
Usage: Should Dragit add overflow styles to container.
Type: Number
Default: null
Usage: Have Dragit add a height (in pixels) to container.
Type: Number
Default: null
Usage: Have Dragit add a width (in pixels) to container.
Usage: Kills the instance of Dragit.
Usage: Creates new instance of Dragit.
MIT License