npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

unidragger

2.3.0 • Public • Published

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 input elements

Install

Bower: bower install unidragger --save

npm: npm install unidragger --save

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 🌈🐻

install

npm i unidragger

Downloadsweekly downloads

59,895

version

2.3.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability