Package Exports
- unidragger
- unidragger/unidragger.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (unidragger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Unidragger
Base draggable class
Used in Flickity and Draggabilly.
Unidragger handles all the event binding and handling to support a draggable library.
Features
- Touch device support: iOS, Android, Microsoft Surface
- Handles click events in
inputelements
Install
npm: npm install unidragger
Yarn: yarn add unidragger
Demo code
// your draggable class
function Dragger( elem ) {
this.element = elem;
}
// use Unidragger as a mixin
extend( Dragger.prototype, Unidragger.prototype );
Dragger.prototype.create = function() {
// set drag handles
this.handles = [ this.element ];
this.bindHandles();
};
Dragger.prototype.dragStart = function( event, pointer ) {
console.log('drag start');
};
Dragger.prototype.dragMove = function( event, pointer, moveVector ) {
var dragX = this.dragStartPoint.x + moveVector.x;
var dragY = this.dragStartPoint.y + moveVector.y;
this.element.style.left = dragX + 'px';
this.element.style.top = dragY + 'px';
};
Dragger.prototype.dragEnd = function( event, pointer ) {
console.log('drag end');
};MIT license
By Metafizzy 🌈🐻