Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dragula

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dragula - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

2

bower.json
{
"name": "dragula.js",
"version": "3.3.0",
"version": "3.3.1",
"description": "Drag and drop so simple it hurts",

@@ -5,0 +5,0 @@ "main": [

@@ -57,2 +57,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.dragula = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var _offsetY; // reference y
var _moveX; // reference move x
var _moveY; // reference move y
var _initialSibling; // reference sibling when grabbed

@@ -104,2 +106,3 @@ var _currentSibling; // reference sibling now

touchy(documentElement, op, 'mouseup', release);
touchy(documentElement, op, 'mousemove', startBecauseMouseMoved);
}

@@ -130,2 +133,5 @@

function grab (e) {
_moveX = e.clientX;
_moveY = e.clientY;
var ignore = (e.which !== 0 && e.which !== 1) || e.metaKey || e.ctrlKey;

@@ -151,2 +157,10 @@ if (ignore) {

function startBecauseMouseMoved (e) {
if (!_grabbed) {
return;
}
if (e.clientX === _moveX && e.clientY === _moveY) {
return;
}
var grabbed = _grabbed; // call to end() unsets _grabbed

@@ -305,3 +319,3 @@ eventualMovements(true);

} else {
drake.emit('drop', item, parent, _source);
drake.emit('drop', item, parent, _source, _currentSibling);
}

@@ -852,2 +866,2 @@ cleanup();

});
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJjbGFzc2VzLmpzIiwiZHJhZ3VsYS5qcyIsIm5vZGVfbW9kdWxlcy9jb250cmEvZGVib3VuY2UuanMiLCJub2RlX21vZHVsZXMvY29udHJhL2VtaXR0ZXIuanMiLCJub2RlX21vZHVsZXMvY29udHJhL25vZGVfbW9kdWxlcy9hdG9hL2F0b2EuanMiLCJub2RlX21vZHVsZXMvY29udHJhL25vZGVfbW9kdWxlcy90aWNreS90aWNreS1icm93c2VyLmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9ub2RlX21vZHVsZXMvY3VzdG9tLWV2ZW50L2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9zcmMvY3Jvc3N2ZW50LmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9zcmMvZXZlbnRtYXAuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7O0FDakNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0F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ZW50bWFwLnB1c2goZXZlbnRuYW1lLnNsaWNlKDIpKTtcbiAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IGV2ZW50bWFwO1xuIl19

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.dragula=e()}}(function(){return function e(n,t,r){function o(u,a){if(!t[u]){if(!n[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(i)return i(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var f=t[u]={exports:{}};n[u][0].call(f.exports,function(e){var t=n[u][1][e];return o(t?t:e)},f,f.exports,e,n,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,n,t){"use strict";function r(e){var n=u[e];return n?n.lastIndex=0:u[e]=n=new RegExp(a+e+c,"g"),n}function o(e,n){var t=e.className;t.length?r(n).test(t)||(e.className+=" "+n):e.className=n}function i(e,n){e.className=e.className.replace(r(n)," ").trim()}var u={},a="(?:^|\\s)",c="(?:\\s|$)";n.exports={add:o,rm:i}},{}],2:[function(e,n,t){(function(t){"use strict";function r(e,n){function t(e){return-1!==re.containers.indexOf(e)||te.isContainer(e)}function r(e){var n=e?"remove":"add";o(ee,n,"mousedown",E),o(ee,n,"mouseup",T)}function u(e){var n=e?"remove":"add";o(ee,n,"mousemove",b)}function v(e){var n=e?"remove":"add";o(ee,n,"selectstart",y),o(ee,n,"click",y)}function g(){r(!0),T({})}function y(e){W&&e.preventDefault()}function E(e){var n=0!==e.which&&1!==e.which||e.metaKey||e.ctrlKey;if(!n){var t=e.target,r=w(t);r&&(W=r,u(),"mousedown"===e.type&&(e.preventDefault(),("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&t.focus()))}}function b(e){var n=W;u(!0),v(),O(),C(n);var t=i(z);H=m("pageX",e)-t.left,V=m("pageY",e)-t.top,h.add(J||z,"gu-transit"),j(),A(e)}function w(e){if(!(re.dragging&&F||t(e))){for(var n=e;e.parentElement&&t(e.parentElement)===!1;){if(te.invalid(e,n))return;if(e=e.parentElement,!e)return}var r=e.parentElement;if(r&&!te.invalid(e,n)){var o=te.moves(e,r,n,s(e));if(o)return{item:e,source:r}}}}function x(e){var n=w(e);n&&C(n)}function C(e){U(e.item,e.source)&&(J=e.item.cloneNode(!0),re.emit("cloned",J,e.item,"copy")),K=e.source,z=e.item,$=G=s(e.item),re.dragging=!0,re.emit("drag",z,K)}function S(){return!1}function O(){if(re.dragging){var e=J||z;B(e,e.parentElement)}}function N(){W=!1,u(!0),v(!0)}function T(e){if(N(),re.dragging){var n=J||z,t=m("clientX",e),r=m("clientY",e),o=a(F,t,r),i=Y(o,t,r);i&&(J&&te.copySortSource||!J||i!==K)?B(n,i):te.removeOnSpill?D():P()}}function B(e,n){var t=e.parentElement;J&&te.copySortSource&&n===K&&t.removeChild(z),R(n)?re.emit("cancel",e,K):re.emit("drop",e,n,K,G),X()}function D(){if(re.dragging){var e=J||z,n=e.parentElement;n&&n.removeChild(e),re.emit(J?"cancel":"remove",e,n),X()}}function P(e){if(re.dragging){var n=arguments.length>0?e:te.revertOnSpill,t=J||z,r=t.parentElement;r===K&&J&&r.removeChild(J);var o=R(r);o===!1&&!J&&n&&K.insertBefore(t,$),o||n?re.emit("cancel",t,K):re.emit("drop",t,r,K),X()}}function X(){var e=J||z;N(),k(),e&&h.rm(e,"gu-transit"),Q&&clearTimeout(Q),re.dragging=!1,re.emit("out",e,ne,K),re.emit("dragend",e),K=z=J=$=G=Q=ne=null}function R(e,n){var t;return t=void 0!==n?n:F?G:s(J||z),e===K&&t===$}function Y(e,n,r){function o(){var o=t(i);if(o===!1)return!1;var u=q(i,e),a=I(i,u,n,r),c=R(i,a);return c?!0:te.accepts(z,i,K,a)}for(var i=e;i&&!o();)i=i.parentElement;return i}function A(e){function n(e){re.emit(e,l,ne,K)}function t(){v&&n("over")}function r(){ne&&n("out")}if(F){e.preventDefault();var o=m("clientX",e),i=m("clientY",e),u=o-H,c=i-V;F.style.left=u+"px",F.style.top=c+"px";var l=J||z,f=a(F,o,i),d=Y(f,o,i),v=null!==d&&d!==ne;if((v||null===d)&&(r(),ne=d,t()),d===K&&J&&!te.copySortSource)return void(l.parentElement&&l.parentElement.removeChild(l));var p,g=q(d,f);if(null!==g)p=I(d,g,o,i);else{if(te.revertOnSpill!==!0||J)return void(J&&l.parentElement&&l.parentElement.removeChild(l));p=$,d=K}(null===p||p!==l&&p!==s(l)&&p!==G)&&(G=p,d.insertBefore(l,p),re.emit("shadow",l,d))}}function L(e){h.rm(e,"gu-hide")}function M(e){re.dragging&&h.add(e,"gu-hide")}function j(){if(!F){var e=z.getBoundingClientRect();F=z.cloneNode(!0),F.style.width=f(e)+"px",F.style.height=d(e)+"px",h.rm(F,"gu-transit"),h.add(F,"gu-mirror"),te.mirrorContainer.appendChild(F),o(ee,"add","mousemove",A),h.add(te.mirrorContainer,"gu-unselectable"),re.emit("cloned",F,z,"mirror")}}function k(){F&&(h.rm(te.mirrorContainer,"gu-unselectable"),o(ee,"remove","mousemove",A),F.parentElement.removeChild(F),F=null)}function q(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===ee?null:t}function I(e,n,t,r){function o(){var n,o,i,u=e.children.length;for(n=0;u>n;n++){if(o=e.children[n],i=o.getBoundingClientRect(),a&&i.left>t)return o;if(!a&&i.top>r)return o}return null}function i(){var e=n.getBoundingClientRect();return u(a?t>e.left+f(e)/2:r>e.top+d(e)/2)}function u(e){return e?s(n):n}var a="horizontal"===te.direction,c=n!==e?i():o();return c}function U(e,n){return"boolean"==typeof te.copy?te.copy:te.copy(e,n)}var _=arguments.length;1===_&&Array.isArray(e)===!1&&(n=e,e=[]);var F,K,z,H,V,$,G,J,Q,W,Z=document.body,ee=document.documentElement,ne=null,te=n||{};void 0===te.moves&&(te.moves=l),void 0===te.accepts&&(te.accepts=l),void 0===te.invalid&&(te.invalid=S),void 0===te.containers&&(te.containers=e||[]),void 0===te.isContainer&&(te.isContainer=c),void 0===te.copy&&(te.copy=!1),void 0===te.revertOnSpill&&(te.revertOnSpill=!1),void 0===te.removeOnSpill&&(te.removeOnSpill=!1),void 0===te.direction&&(te.direction="vertical"),void 0===te.mirrorContainer&&(te.mirrorContainer=Z),void 0===te.copySortSource&&(te.copySortSource=!1);var re=p({containers:te.containers,start:x,end:O,cancel:P,remove:D,destroy:g,dragging:!1});return te.removeOnSpill===!0&&re.on("over",L).on("out",M),r(),re}function o(e,n,r,o){var i={mouseup:"touchend",mousedown:"touchstart",mousemove:"touchmove"},u={mouseup:"MSPointerUp",mousedown:"MSPointerDown",mousemove:"MSPointerMove"};t.navigator.msPointerEnabled&&g[n](e,u[r],o),g[n](e,i[r],o),g[n](e,r,o)}function i(e){var n=e.getBoundingClientRect();return{left:n.left+u("scrollLeft","pageXOffset"),top:n.top+u("scrollTop","pageYOffset")}}function u(e,n){if("undefined"!=typeof t[n])return t[n];var r=document.documentElement;if(r.clientHeight)return r[e];var o=document.body;return o[e]}function a(e,n,t){var r,o=e||{},i=o.className;return o.className+=" gu-hide",r=document.elementFromPoint(n,t),o.className=i,r}function c(){return!1}function l(){return!0}function f(e){return e.width||e.right-e.left}function d(e){return e.height||e.bottom-e.top}function s(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function v(e){return e.targetTouches&&e.targetTouches.length?e.targetTouches[0]:e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e}function m(e,n){var t=v(n),r={pageX:"clientX",pageY:"clientY"};return e in r&&!(e in t)&&r[e]in t&&(e=r[e]),t[e]}var p=e("contra/emitter"),g=e("crossvent"),h=e("./classes");n.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./classes":1,"contra/emitter":4,crossvent:8}],3:[function(e,n,t){"use strict";var r=e("ticky");n.exports=function(e,n,t){e&&r(function(){e.apply(t||null,n||[])})}},{ticky:6}],4:[function(e,n,t){"use strict";var r=e("atoa"),o=e("./debounce");n.exports=function(e,n){var t=n||{},i={};return void 0===e&&(e={}),e.on=function(n,t){return i[n]?i[n].push(t):i[n]=[t],e},e.once=function(n,t){return t._once=!0,e.on(n,t),e},e.off=function(n,t){var r=arguments.length;if(1===r)delete i[n];else if(0===r)i={};else{var o=i[n];if(!o)return e;o.splice(o.indexOf(t),1)}return e},e.emit=function(){var n=r(arguments);return e.emitterSnapshot(n.shift()).apply(this,n)},e.emitterSnapshot=function(n){var u=(i[n]||[]).slice(0);return function(){var i=r(arguments),a=this||e;if("error"===n&&t["throws"]!==!1&&!u.length)throw 1===i.length?i[0]:i;return u.forEach(function(r){t.async?o(r,i,a):r.apply(a,i),r._once&&e.off(n,r)}),e}},e}},{"./debounce":3,atoa:5}],5:[function(e,n,t){n.exports=function(e,n){return Array.prototype.slice.call(e,n)}},{}],6:[function(e,n,t){var r,o="function"==typeof setImmediate;r=o?function(e){setImmediate(e)}:function(e){setTimeout(e,0)},n.exports=r},{}],7:[function(e,n,t){(function(e){function t(){try{var e=new r("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(n){}return!1}var r=e.CustomEvent;n.exports=t()?r:"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=Boolean(n.bubbles),t.cancelable=Boolean(n.cancelable),t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,n,t){(function(t){"use strict";function r(e,n,t,r){return e.addEventListener(n,t,r)}function o(e,n,t){return e.attachEvent("on"+n,l(e,n,t))}function i(e,n,t,r){return e.removeEventListener(n,t,r)}function u(e,n,t){var r=f(e,n,t);return r?e.detachEvent("on"+n,r):void 0}function a(e,n,t){function r(){var e;return m.createEvent?(e=m.createEvent("Event"),e.initEvent(n,!0,!0)):m.createEventObject&&(e=m.createEventObject()),e}function o(){return new s(n,{detail:t})}var i=-1===v.indexOf(n)?o():r();e.dispatchEvent?e.dispatchEvent(i):e.fireEvent("on"+n,i)}function c(e,n,r){return function(n){var o=n||t.event;o.target=o.target||o.srcElement,o.preventDefault=o.preventDefault||function(){o.returnValue=!1},o.stopPropagation=o.stopPropagation||function(){o.cancelBubble=!0},o.which=o.which||o.keyCode,r.call(e,o)}}function l(e,n,t){var r=f(e,n,t)||c(e,n,t);return h.push({wrapper:r,element:e,type:n,fn:t}),r}function f(e,n,t){var r=d(e,n,t);if(r){var o=h[r].wrapper;return h.splice(r,1),o}}function d(e,n,t){var r,o;for(r=0;r<h.length;r++)if(o=h[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=e("custom-event"),v=e("./eventmap"),m=t.document,p=r,g=i,h=[];t.addEventListener||(p=o,g=u),n.exports={add:p,remove:g,fabricate:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./eventmap":9,"custom-event":7}],9:[function(e,n,t){(function(e){"use strict";var t=[],r="",o=/^on/;for(r in e)o.test(r)&&t.push(r.slice(2));n.exports=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.dragula=e()}}(function(){return function e(n,t,r){function o(u,a){if(!t[u]){if(!n[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(i)return i(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var f=t[u]={exports:{}};n[u][0].call(f.exports,function(e){var t=n[u][1][e];return o(t?t:e)},f,f.exports,e,n,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,n,t){"use strict";function r(e){var n=u[e];return n?n.lastIndex=0:u[e]=n=new RegExp(a+e+c,"g"),n}function o(e,n){var t=e.className;t.length?r(n).test(t)||(e.className+=" "+n):e.className=n}function i(e,n){e.className=e.className.replace(r(n)," ").trim()}var u={},a="(?:^|\\s)",c="(?:\\s|$)";n.exports={add:o,rm:i}},{}],2:[function(e,n,t){(function(t){"use strict";function r(e,n){function t(e){return-1!==ie.containers.indexOf(e)||oe.isContainer(e)}function r(e){var n=e?"remove":"add";o(te,n,"mousedown",E),o(te,n,"mouseup",T),o(te,n,"mousemove",b)}function u(e){var n=e?"remove":"add";o(te,n,"mousemove",b)}function v(e){var n=e?"remove":"add";o(te,n,"selectstart",y),o(te,n,"click",y)}function g(){r(!0),T({})}function y(e){ee&&e.preventDefault()}function E(e){$=e.clientX,G=e.clientY;var n=0!==e.which&&1!==e.which||e.metaKey||e.ctrlKey;if(!n){var t=e.target,r=w(t);r&&(ee=r,u(),"mousedown"===e.type&&(e.preventDefault(),("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&t.focus()))}}function b(e){if(ee&&(e.clientX!==$||e.clientY!==G)){var n=ee;u(!0),v(),O(),C(n);var t=i(z);H=m("pageX",e)-t.left,V=m("pageY",e)-t.top,h.add(W||z,"gu-transit"),j(),A(e)}}function w(e){if(!(ie.dragging&&F||t(e))){for(var n=e;e.parentElement&&t(e.parentElement)===!1;){if(oe.invalid(e,n))return;if(e=e.parentElement,!e)return}var r=e.parentElement;if(r&&!oe.invalid(e,n)){var o=oe.moves(e,r,n,s(e));if(o)return{item:e,source:r}}}}function x(e){var n=w(e);n&&C(n)}function C(e){U(e.item,e.source)&&(W=e.item.cloneNode(!0),ie.emit("cloned",W,e.item,"copy")),K=e.source,z=e.item,J=Q=s(e.item),ie.dragging=!0,ie.emit("drag",z,K)}function S(){return!1}function O(){if(ie.dragging){var e=W||z;B(e,e.parentElement)}}function N(){ee=!1,u(!0),v(!0)}function T(e){if(N(),ie.dragging){var n=W||z,t=m("clientX",e),r=m("clientY",e),o=a(F,t,r),i=R(o,t,r);i&&(W&&oe.copySortSource||!W||i!==K)?B(n,i):oe.removeOnSpill?X():D()}}function B(e,n){var t=e.parentElement;W&&oe.copySortSource&&n===K&&t.removeChild(z),Y(n)?ie.emit("cancel",e,K):ie.emit("drop",e,n,K,Q),P()}function X(){if(ie.dragging){var e=W||z,n=e.parentElement;n&&n.removeChild(e),ie.emit(W?"cancel":"remove",e,n),P()}}function D(e){if(ie.dragging){var n=arguments.length>0?e:oe.revertOnSpill,t=W||z,r=t.parentElement;r===K&&W&&r.removeChild(W);var o=Y(r);o===!1&&!W&&n&&K.insertBefore(t,J),o||n?ie.emit("cancel",t,K):ie.emit("drop",t,r,K,Q),P()}}function P(){var e=W||z;N(),k(),e&&h.rm(e,"gu-transit"),Z&&clearTimeout(Z),ie.dragging=!1,ie.emit("out",e,re,K),ie.emit("dragend",e),K=z=W=J=Q=Z=re=null}function Y(e,n){var t;return t=void 0!==n?n:F?Q:s(W||z),e===K&&t===J}function R(e,n,r){function o(){var o=t(i);if(o===!1)return!1;var u=q(i,e),a=I(i,u,n,r),c=Y(i,a);return c?!0:oe.accepts(z,i,K,a)}for(var i=e;i&&!o();)i=i.parentElement;return i}function A(e){function n(e){ie.emit(e,l,re,K)}function t(){v&&n("over")}function r(){re&&n("out")}if(F){e.preventDefault();var o=m("clientX",e),i=m("clientY",e),u=o-H,c=i-V;F.style.left=u+"px",F.style.top=c+"px";var l=W||z,f=a(F,o,i),d=R(f,o,i),v=null!==d&&d!==re;if((v||null===d)&&(r(),re=d,t()),d===K&&W&&!oe.copySortSource)return void(l.parentElement&&l.parentElement.removeChild(l));var p,g=q(d,f);if(null!==g)p=I(d,g,o,i);else{if(oe.revertOnSpill!==!0||W)return void(W&&l.parentElement&&l.parentElement.removeChild(l));p=J,d=K}(null===p||p!==l&&p!==s(l)&&p!==Q)&&(Q=p,d.insertBefore(l,p),ie.emit("shadow",l,d))}}function L(e){h.rm(e,"gu-hide")}function M(e){ie.dragging&&h.add(e,"gu-hide")}function j(){if(!F){var e=z.getBoundingClientRect();F=z.cloneNode(!0),F.style.width=f(e)+"px",F.style.height=d(e)+"px",h.rm(F,"gu-transit"),h.add(F,"gu-mirror"),oe.mirrorContainer.appendChild(F),o(te,"add","mousemove",A),h.add(oe.mirrorContainer,"gu-unselectable"),ie.emit("cloned",F,z,"mirror")}}function k(){F&&(h.rm(oe.mirrorContainer,"gu-unselectable"),o(te,"remove","mousemove",A),F.parentElement.removeChild(F),F=null)}function q(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===te?null:t}function I(e,n,t,r){function o(){var n,o,i,u=e.children.length;for(n=0;u>n;n++){if(o=e.children[n],i=o.getBoundingClientRect(),a&&i.left>t)return o;if(!a&&i.top>r)return o}return null}function i(){var e=n.getBoundingClientRect();return u(a?t>e.left+f(e)/2:r>e.top+d(e)/2)}function u(e){return e?s(n):n}var a="horizontal"===oe.direction,c=n!==e?i():o();return c}function U(e,n){return"boolean"==typeof oe.copy?oe.copy:oe.copy(e,n)}var _=arguments.length;1===_&&Array.isArray(e)===!1&&(n=e,e=[]);var F,K,z,H,V,$,G,J,Q,W,Z,ee,ne=document.body,te=document.documentElement,re=null,oe=n||{};void 0===oe.moves&&(oe.moves=l),void 0===oe.accepts&&(oe.accepts=l),void 0===oe.invalid&&(oe.invalid=S),void 0===oe.containers&&(oe.containers=e||[]),void 0===oe.isContainer&&(oe.isContainer=c),void 0===oe.copy&&(oe.copy=!1),void 0===oe.revertOnSpill&&(oe.revertOnSpill=!1),void 0===oe.removeOnSpill&&(oe.removeOnSpill=!1),void 0===oe.direction&&(oe.direction="vertical"),void 0===oe.mirrorContainer&&(oe.mirrorContainer=ne),void 0===oe.copySortSource&&(oe.copySortSource=!1);var ie=p({containers:oe.containers,start:x,end:O,cancel:D,remove:X,destroy:g,dragging:!1});return oe.removeOnSpill===!0&&ie.on("over",L).on("out",M),r(),ie}function o(e,n,r,o){var i={mouseup:"touchend",mousedown:"touchstart",mousemove:"touchmove"},u={mouseup:"MSPointerUp",mousedown:"MSPointerDown",mousemove:"MSPointerMove"};t.navigator.msPointerEnabled&&g[n](e,u[r],o),g[n](e,i[r],o),g[n](e,r,o)}function i(e){var n=e.getBoundingClientRect();return{left:n.left+u("scrollLeft","pageXOffset"),top:n.top+u("scrollTop","pageYOffset")}}function u(e,n){if("undefined"!=typeof t[n])return t[n];var r=document.documentElement;if(r.clientHeight)return r[e];var o=document.body;return o[e]}function a(e,n,t){var r,o=e||{},i=o.className;return o.className+=" gu-hide",r=document.elementFromPoint(n,t),o.className=i,r}function c(){return!1}function l(){return!0}function f(e){return e.width||e.right-e.left}function d(e){return e.height||e.bottom-e.top}function s(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function v(e){return e.targetTouches&&e.targetTouches.length?e.targetTouches[0]:e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e}function m(e,n){var t=v(n),r={pageX:"clientX",pageY:"clientY"};return e in r&&!(e in t)&&r[e]in t&&(e=r[e]),t[e]}var p=e("contra/emitter"),g=e("crossvent"),h=e("./classes");n.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./classes":1,"contra/emitter":4,crossvent:8}],3:[function(e,n,t){"use strict";var r=e("ticky");n.exports=function(e,n,t){e&&r(function(){e.apply(t||null,n||[])})}},{ticky:6}],4:[function(e,n,t){"use strict";var r=e("atoa"),o=e("./debounce");n.exports=function(e,n){var t=n||{},i={};return void 0===e&&(e={}),e.on=function(n,t){return i[n]?i[n].push(t):i[n]=[t],e},e.once=function(n,t){return t._once=!0,e.on(n,t),e},e.off=function(n,t){var r=arguments.length;if(1===r)delete i[n];else if(0===r)i={};else{var o=i[n];if(!o)return e;o.splice(o.indexOf(t),1)}return e},e.emit=function(){var n=r(arguments);return e.emitterSnapshot(n.shift()).apply(this,n)},e.emitterSnapshot=function(n){var u=(i[n]||[]).slice(0);return function(){var i=r(arguments),a=this||e;if("error"===n&&t["throws"]!==!1&&!u.length)throw 1===i.length?i[0]:i;return u.forEach(function(r){t.async?o(r,i,a):r.apply(a,i),r._once&&e.off(n,r)}),e}},e}},{"./debounce":3,atoa:5}],5:[function(e,n,t){n.exports=function(e,n){return Array.prototype.slice.call(e,n)}},{}],6:[function(e,n,t){var r,o="function"==typeof setImmediate;r=o?function(e){setImmediate(e)}:function(e){setTimeout(e,0)},n.exports=r},{}],7:[function(e,n,t){(function(e){function t(){try{var e=new r("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(n){}return!1}var r=e.CustomEvent;n.exports=t()?r:"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=Boolean(n.bubbles),t.cancelable=Boolean(n.cancelable),t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,n,t){(function(t){"use strict";function r(e,n,t,r){return e.addEventListener(n,t,r)}function o(e,n,t){return e.attachEvent("on"+n,l(e,n,t))}function i(e,n,t,r){return e.removeEventListener(n,t,r)}function u(e,n,t){var r=f(e,n,t);return r?e.detachEvent("on"+n,r):void 0}function a(e,n,t){function r(){var e;return m.createEvent?(e=m.createEvent("Event"),e.initEvent(n,!0,!0)):m.createEventObject&&(e=m.createEventObject()),e}function o(){return new s(n,{detail:t})}var i=-1===v.indexOf(n)?o():r();e.dispatchEvent?e.dispatchEvent(i):e.fireEvent("on"+n,i)}function c(e,n,r){return function(n){var o=n||t.event;o.target=o.target||o.srcElement,o.preventDefault=o.preventDefault||function(){o.returnValue=!1},o.stopPropagation=o.stopPropagation||function(){o.cancelBubble=!0},o.which=o.which||o.keyCode,r.call(e,o)}}function l(e,n,t){var r=f(e,n,t)||c(e,n,t);return h.push({wrapper:r,element:e,type:n,fn:t}),r}function f(e,n,t){var r=d(e,n,t);if(r){var o=h[r].wrapper;return h.splice(r,1),o}}function d(e,n,t){var r,o;for(r=0;r<h.length;r++)if(o=h[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=e("custom-event"),v=e("./eventmap"),m=t.document,p=r,g=i,h=[];t.addEventListener||(p=o,g=u),n.exports={add:p,remove:g,fabricate:a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./eventmap":9,"custom-event":7}],9:[function(e,n,t){(function(e){"use strict";var t=[],r="",o=/^on/;for(r in e)o.test(r)&&t.push(r.slice(2));n.exports=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)});

@@ -20,2 +20,4 @@ 'use strict';

var _offsetY; // reference y
var _moveX; // reference move x
var _moveY; // reference move y
var _initialSibling; // reference sibling when grabbed

@@ -67,2 +69,3 @@ var _currentSibling; // reference sibling now

touchy(documentElement, op, 'mouseup', release);
touchy(documentElement, op, 'mousemove', startBecauseMouseMoved);
}

@@ -93,2 +96,5 @@

function grab (e) {
_moveX = e.clientX;
_moveY = e.clientY;
var ignore = (e.which !== 0 && e.which !== 1) || e.metaKey || e.ctrlKey;

@@ -114,2 +120,10 @@ if (ignore) {

function startBecauseMouseMoved (e) {
if (!_grabbed) {
return;
}
if (e.clientX === _moveX && e.clientY === _moveY) {
return;
}
var grabbed = _grabbed; // call to end() unsets _grabbed

@@ -268,3 +282,3 @@ eventualMovements(true);

} else {
drake.emit('drop', item, parent, _source);
drake.emit('drop', item, parent, _source, _currentSibling);
}

@@ -271,0 +285,0 @@ cleanup();

{
"name": "dragula",
"version": "3.3.0",
"version": "3.3.1",
"description": "Drag and drop so simple it hurts",

@@ -5,0 +5,0 @@ "main": "dragula.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc