A tiny (5KB) package to allow free dragging of HTML elements.
npm install --save vanilla-dragimport VanillaDrag from 'vanilla-drag';
const target = document.getElementById('target');
const drag = new VanillaDrag(window, target);The VanillaDrag constructor takes two arguments.
new VanillaDrag([window], [HTMLElement])The current context's window object. 99% of the time this will always be a case of passing in the global window object.
An instance of a HTMLElement that will have dragging enabled. Jquery users can access an instance of this object using the following Jquery index / method $('#target')[0] or $('#target').get(0). For Jquery collections containing multiple elements, the collection will need to be iterated over and a separate instance of VanillaDrag created for each item.