listen to and fire a drag event on a dom element
Listen to horizontal drag events on a dom element. drag-listener will not actually move the element around for you, it will just notify you of the user's attempt to drag the element.
npm install drag-listener
drag-listener has some fairly strict environmental requirements in that it
must be used in conjunction with browserify (hence the npm distribution). It
$ in the global scope to reference jQuery at runtime.
listen(element, [handle,] offsetMin, offsetMax)
Start listening for drag events on an element. Returns an EventEmitter that emits the events in the events section below.
elementthe element that will have its position measured to return a value for the drag event. For more details, on how this is measured, see the
handle(optional) - the handle of the draggable element, this is the thing that user clicks on to start dragging. Defaults to
offsetMinthe minimum bound of the draggable element. Can also be passed as a function that returns a number (the function is called at the start of each drag to determine the minimum bound for that drag)
offsetMaxthe maximum bound of the draggable element. Can also be passed as a function that returns a number (the function is called at the start of each drag to determine the maximum bound for that drag)
dragStart- emitted when the user initiates a drag (when the handle receives a mousedown event). Does not pass any arguments.
drag- emitted when the user drags the element (fired for every mousemove event received after the handle has received a mousedown event, but before it has received a mouseup event). Passes one argument, a number between 0.0 and 1.0 that indicates where the user has dragged the element between the
dragFinish- emitted when the user finishes a drag (when the handle receives a mouseup event). Does not pass any arguments.