jquery-dragEvents

simple jQuery drag events


Install
bower install jquery-dragEvents

Documentation

Simple jQuery drag events

var $foo = $('#foo');

$foo.registerDragEvents();

$foo.on('dragstart', function (e) {
   console.log('dragstart', e);
});

$foo.on('drag', function (e) {
    console.log('drag', e);
});

$foo.on('dragstop', function (e) {
    console.log('dragstop', e);
});

Event Properties

Each of the event objects passed into the drag callbacks have the following properties.

{
  x: <current pageX>,
  y: <current pageY>,
  startX: <pageX on dragstart>,
  startY: <pageY on dragstart>,
  offsetX: <difference between x and startX>,
  offsetY: <difference between y and startY>
}

Notes

$.registerDragEvents takes an optional parameter which limits the scope of the page which is watched for drag events. This patameter defaults to document.