Socket
Socket
Sign inDemoInstall

dragula

Package Overview
Dependencies
3
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.1 to 1.4.2

2

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

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

@@ -7,6 +7,6 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.dragula=e()}}(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 crossvent = require('crossvent');
var body = document.body;
var documentElement = document.documentElement;
function dragula (containers, options) {
function dragula (initialContainers, options) {
var body = document.body;
var documentElement = document.documentElement;
var _mirror; // mirror image

@@ -20,2 +20,3 @@ var _source; // source container

var _copy; // item used for copying
var _containers = []; // containers managed by the drake

@@ -42,2 +43,3 @@ var o = options || {};

events();
api.addContainer(initialContainers);

@@ -48,7 +50,15 @@ return api;

return function addOrRemove (all) {
var containers = Array.isArray(all) ? all : [all];
containers.forEach(track);
var changes = Array.isArray(all) ? all : [all];
changes.forEach(track);
if (op === 'add') {
_containers = _containers.concat(changes);
} else {
_containers = _containers.filter(removals);
}
function track (container) {
touchy(container, op, 'mousedown', grab);
}
function removals (container) {
return changes.indexOf(container) === -1;
}
};

@@ -60,3 +70,2 @@ }

touchy(documentElement, op, 'mouseup', release);
api[op + 'Container'](containers);
}

@@ -66,2 +75,3 @@

events(true);
api.removeContainer(_containers);
release({});

@@ -93,6 +103,6 @@ }

if (containers.indexOf(item) !== -1) {
if (_containers.indexOf(item) !== -1) {
return; // don't drag container itself
}
while (containers.indexOf(item.parentElement) === -1) {
while (_containers.indexOf(item.parentElement) === -1) {
if (invalidTarget(item)) {

@@ -236,3 +246,3 @@ return;

function accepted () {
var droppable = containers.indexOf(target) !== -1;
var droppable = _containers.indexOf(target) !== -1;
if (droppable === false) {

@@ -381,5 +391,7 @@ return false;

}
var documentElement = document.documentElement;
if (documentElement.clientHeight) {
return documentElement[scrollProp];
}
var body = document.body;
return body[scrollProp];

@@ -672,2 +684,2 @@ }

});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJkcmFndWxhLmpzIiwibm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL3Byb2Nlc3MvYnJvd3Nlci5qcyIsIm5vZGVfbW9kdWxlcy9jb250cmEuZW1pdHRlci9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9jb250cmEuZW1pdHRlci9zcmMvY29udHJhLmVtaXR0ZXIuanMiLCJub2RlX21vZHVsZXMvY3Jvc3N2ZW50L3NyYy9jcm9zc3ZlbnQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0FDQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0F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module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.dragula=e()}}(function(){return function e(n,t,r){function o(u,c){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!c&&a)return a(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[u]={exports:{}};n[u][0].call(l.exports,function(e){var t=n[u][1][e];return o(t?t:e)},l,l.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){(function(t){"use strict";function r(e,n){function t(e){return function(n){function t(n){o(n,e,"mousedown",v)}var r=Array.isArray(n)?n:[n];r.forEach(t)}}function r(n){var t=n?"remove":"add";o(g,t,"mouseup",E),Y[t+"Container"](e)}function u(){r(!0),E({})}function v(e){var n=e.target;if(!(0!==e.which&&1!==e.which||e.metaKey||e.ctrlKey)&&h(n)===!0){var t=i(A);M=d("pageX",e)-t.left,R=d("pageY",e)-t.top,B(),C(e),e.preventDefault()}}function h(n){if(!(Y.dragging&&_||-1!==e.indexOf(n))){for(;-1===e.indexOf(n.parentElement);){if(y(n))return;n=n.parentElement}if(!y(n)){var t=n.parentElement,r=X.moves(n,t);if(r)return w(),X.copy?(U=n.cloneNode(!0),l(U,"gu-transit")):l(n,"gu-transit"),j=t,A=n,k=q=f(n),Y.dragging=!0,Y.emit("drag",A,j),!0}}}function y(e){return"A"===e.tagName||"BUTTON"===e.tagName}function w(){if(Y.dragging){var e=U||A;x(e,e.parentElement)}}function E(e){if(Y.dragging){var n=U||A,t=d("clientX",e),r=d("clientY",e),o=c(_,t,r),i=S(o,t,r);!i||X.copy!==!1&&i===j?X.removeOnSpill?b():O():x(n,i)}}function x(e,n){T(n)?Y.emit("cancel",e,j):Y.emit("drop",e,n,j),N()}function b(){if(Y.dragging){var e=U||A,n=e.parentElement;n&&n.removeChild(e),Y.emit(X.copy?"cancel":"remove",e,n),N()}}function O(e){if(Y.dragging){var n=arguments.length>0?e:X.revertOnSpill,t=U||A,r=t.parentElement;r===j&&X.copy&&r.removeChild(U);var o=T(r);o===!1&&X.copy===!1&&n&&j.insertBefore(t,k),o||n?Y.emit("cancel",t,j):Y.emit("drop",t,r,j),N()}}function N(){var e=U||A;L(),s(e,"gu-transit"),j=A=U=k=q=null,Y.dragging=!1,Y.emit("dragend",e)}function T(e,n){var t;return t=void 0!==n?n:_?q:f(A||U),e===j&&t===k}function S(n,t,r){function o(){var o=-1!==e.indexOf(i);if(o===!1)return!1;var u=P(i,n),c=D(i,u,t,r),a=T(i,c);return a?!0:X.accepts(A,i,j,c)}for(var i=n;i&&!o();)i=i.parentElement;return i}function C(e){if(_){var n=d("clientX",e),t=d("clientY",e),r=n-M,o=t-R;_.style.left=r+"px",_.style.top=o+"px";var i=c(_,n,t),u=S(i,n,t);if(u!==j||!X.copy){var a=U||A,l=P(u,i);if(null!==l){var s=D(u,l,n,t);(null===s||s!==a&&s!==f(a))&&(q=s,u.insertBefore(a,s),Y.emit("shadow",a,u))}}}}function B(){if(!_){var e=A.getBoundingClientRect();_=A.cloneNode(!0),_.style.width=e.width+"px",_.style.height=e.height+"px",s(_,"gu-transit"),l(_," gu-mirror"),m.appendChild(_),o(g,"add","mousemove",C),l(m,"gu-unselectable")}}function L(){_&&(s(m,"gu-unselectable"),o(g,"remove","mousemove",C),_.parentElement.removeChild(_),_=null)}function P(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===g?null:t}function D(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(),c&&i.left>t)return o;if(!c&&i.top>r)return o}return null}function i(){var e=n.getBoundingClientRect();return u(c?t>e.left+e.width/2:r>e.top+e.height/2)}function u(e){return e?f(n):n}var c="horizontal"===X.direction,a=n!==e?i():o();return a}var _,j,A,M,R,k,q,U,X=n||{};void 0===X.moves&&(X.moves=a),void 0===X.accepts&&(X.accepts=a),void 0===X.copy&&(X.copy=!1),void 0===X.revertOnSpill&&(X.revertOnSpill=!1),void 0===X.removeOnSpill&&(X.removeOnSpill=!1),void 0===X.direction&&(X.direction="vertical");var Y=p({addContainer:t("add"),removeContainer:t("remove"),start:h,end:w,cancel:O,remove:b,destroy:u,dragging:!1});return r(),Y}function o(e,n,r,o){var i={mouseup:"touchend",mousedown:"touchstart",mousemove:"touchmove"},u={mouseup:"MSPointerUp",mousedown:"MSPointerDown",mousemove:"MSPointerMove"};t.navigator.msPointerEnabled&&v[n](e,u[r],o),v[n](e,i[r],o),v[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){return"undefined"!=typeof t[n]?t[n]:g.clientHeight?g[e]:m[e]}function c(e,n,t){if(!n&&!t)return null;var r,o=e||{},i=o.className;return o.className+=" gu-hide",r=document.elementFromPoint(n,t),o.className=i,r}function a(){return!0}function f(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function l(e,n){-1===e.className.indexOf(" "+n)&&(e.className+=" "+n)}function s(e,n){e.className=e.className.replace(new RegExp(" "+n,"g"),"")}function d(e,n){return"undefined"==typeof n.targetTouches?n[e]:n.targetTouches&&n.targetTouches.length&&n.targetTouches[0][e]||0}var p=e("contra.emitter"),v=e("crossvent"),m=document.body,g=document.documentElement;n.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"contra.emitter":3,crossvent:5}],2:[function(e,n){function t(){if(!u){u=!0;for(var e,n=i.length;n;){e=i,i=[];for(var t=-1;++t<n;)e[t]();n=i.length}u=!1}}function r(){}var o=n.exports={},i=[],u=!1;o.nextTick=function(e){i.push(e),u||setTimeout(t,0)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=r,o.addListener=r,o.once=r,o.off=r,o.removeListener=r,o.removeAllListeners=r,o.emit=r,o.binding=function(){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],3:[function(e,n){n.exports=e("./src/contra.emitter.js")},{"./src/contra.emitter.js":4}],4:[function(e,n){(function(e){!function(t,r){"use strict";function o(e,n){return Array.prototype.slice.call(e,n)}function i(e,n,t){e&&c(function(){e.apply(t||null,n||[])})}function u(e,n){var t=n||{},u={};return e===r&&(e={}),e.on=function(n,t){return u[n]?u[n].push(t):u[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 u[n];else if(0===r)u={};else{var o=u[n];if(!o)return e;o.splice(o.indexOf(t),1)}return e},e.emit=function(){var n=o(arguments);return e.emitterSnapshot(n.shift()).apply(this,n)},e.emitterSnapshot=function(n){var r=(u[n]||[]).slice(0);return function(){var c=o(arguments),a=this||e;if("error"===n&&t["throws"]!==!1&&!r.length)throw 1===c.length?c[0]:c;return u[n]=r.filter(function(e){return t.async?i(e,c,a):e.apply(a,c),!e._once}),e}},e}var c,a=""+r,f="function"==typeof setImmediate;c=f?function(e){setImmediate(e)}:typeof e!==a&&e.nextTick?e.nextTick:function(e){setTimeout(e,0)},typeof n!==a&&n.exports?n.exports=u:(t.contra=t.contra||{},t.contra.emitter=u)}(this)}).call(this,e("_process"))},{_process:2}],5:[function(e,n){(function(e){"use strict";function t(e,n,t,r){return e.addEventListener(n,t,r)}function r(e,n,t){return e.attachEvent("on"+n,a(e,n,t))}function o(e,n,t,r){return e.removeEventListener(n,t,r)}function i(e,n,t){return e.detachEvent("on"+n,f(e,n,t))}function u(e,n){var t;s.createEvent?(t=s.createEvent("Event"),t.initEvent(n,!0,!0),e.dispatchEvent(t)):s.createEventObject&&(t=s.createEventObject(),e.fireEvent("on"+n,t))}function c(n,t,r){return function(t){var o=t||e.event;o.target=o.target||o.srcElement,o.preventDefault=o.preventDefault||function(){o.returnValue=!1},o.stopPropagation=o.stopPropagation||function(){o.cancelBubble=!0},r.call(n,o)}}function a(e,n,t){var r=f(e,n,t)||c(e,n,t);return v.push({wrapper:r,element:e,type:n,fn:t}),r}function f(e,n,t){var r=l(e,n,t);if(r){var o=v[r].wrapper;return v.splice(r,1),o}}function l(e,n,t){var r,o;for(r=0;r<v.length;r++)if(o=v[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=document,d=t,p=o,v=[];e.addEventListener||(d=r,p=i),n.exports={add:d,remove:p,fabricate:u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(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;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.dragula=e()}}(function(){return function e(n,t,r){function o(u,c){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!c&&a)return a(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[u]={exports:{}};n[u][0].call(l.exports,function(e){var t=n[u][1][e];return o(t?t:e)},l,l.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){(function(t){"use strict";function r(e,n){function t(e){return function(n){function t(n){o(n,e,"mousedown",v)}function r(e){return-1===i.indexOf(e)}var i=Array.isArray(n)?n:[n];i.forEach(t),X="add"===e?X.concat(i):X.filter(r)}}function r(e){var n=e?"remove":"add";o(U,n,"mouseup",y)}function u(){r(!0),F.removeContainer(X),y({})}function v(e){var n=e.target;if(!(0!==e.which&&1!==e.which||e.metaKey||e.ctrlKey)&&m(n)===!0){var t=i(_);j=d("pageX",e)-t.left,A=d("pageY",e)-t.top,C(),T(e),e.preventDefault()}}function m(e){if(!(F.dragging&&P||-1!==X.indexOf(e))){for(;-1===X.indexOf(e.parentElement);){if(g(e))return;e=e.parentElement}if(!g(e)){var n=e.parentElement,t=Y.moves(e,n);if(t)return h(),Y.copy?(k=e.cloneNode(!0),l(k,"gu-transit")):l(e,"gu-transit"),D=n,_=e,M=R=f(e),F.dragging=!0,F.emit("drag",_,D),!0}}}function g(e){return"A"===e.tagName||"BUTTON"===e.tagName}function h(){if(F.dragging){var e=k||_;w(e,e.parentElement)}}function y(e){if(F.dragging){var n=k||_,t=d("clientX",e),r=d("clientY",e),o=c(P,t,r),i=N(o,t,r);!i||Y.copy!==!1&&i===D?Y.removeOnSpill?E():x():w(n,i)}}function w(e,n){O(n)?F.emit("cancel",e,D):F.emit("drop",e,n,D),b()}function E(){if(F.dragging){var e=k||_,n=e.parentElement;n&&n.removeChild(e),F.emit(Y.copy?"cancel":"remove",e,n),b()}}function x(e){if(F.dragging){var n=arguments.length>0?e:Y.revertOnSpill,t=k||_,r=t.parentElement;r===D&&Y.copy&&r.removeChild(k);var o=O(r);o===!1&&Y.copy===!1&&n&&D.insertBefore(t,M),o||n?F.emit("cancel",t,D):F.emit("drop",t,r,D),b()}}function b(){var e=k||_;S(),s(e,"gu-transit"),D=_=k=M=R=null,F.dragging=!1,F.emit("dragend",e)}function O(e,n){var t;return t=void 0!==n?n:P?R:f(_||k),e===D&&t===M}function N(e,n,t){function r(){var r=-1!==X.indexOf(o);if(r===!1)return!1;var i=B(o,e),u=L(o,i,n,t),c=O(o,u);return c?!0:Y.accepts(_,o,D,u)}for(var o=e;o&&!r();)o=o.parentElement;return o}function T(e){if(P){var n=d("clientX",e),t=d("clientY",e),r=n-j,o=t-A;P.style.left=r+"px",P.style.top=o+"px";var i=c(P,n,t),u=N(i,n,t);if(u!==D||!Y.copy){var a=k||_,l=B(u,i);if(null!==l){var s=L(u,l,n,t);(null===s||s!==a&&s!==f(a))&&(R=s,u.insertBefore(a,s),F.emit("shadow",a,u))}}}}function C(){if(!P){var e=_.getBoundingClientRect();P=_.cloneNode(!0),P.style.width=e.width+"px",P.style.height=e.height+"px",s(P,"gu-transit"),l(P," gu-mirror"),q.appendChild(P),o(U,"add","mousemove",T),l(q,"gu-unselectable")}}function S(){P&&(s(q,"gu-unselectable"),o(U,"remove","mousemove",T),P.parentElement.removeChild(P),P=null)}function B(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===U?null:t}function L(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(),c&&i.left>t)return o;if(!c&&i.top>r)return o}return null}function i(){var e=n.getBoundingClientRect();return u(c?t>e.left+e.width/2:r>e.top+e.height/2)}function u(e){return e?f(n):n}var c="horizontal"===Y.direction,a=n!==e?i():o();return a}var P,D,_,j,A,M,R,k,q=document.body,U=document.documentElement,X=[],Y=n||{};void 0===Y.moves&&(Y.moves=a),void 0===Y.accepts&&(Y.accepts=a),void 0===Y.copy&&(Y.copy=!1),void 0===Y.revertOnSpill&&(Y.revertOnSpill=!1),void 0===Y.removeOnSpill&&(Y.removeOnSpill=!1),void 0===Y.direction&&(Y.direction="vertical");var F=p({addContainer:t("add"),removeContainer:t("remove"),start:m,end:h,cancel:x,remove:E,destroy:u,dragging:!1});return r(),F.addContainer(e),F}function o(e,n,r,o){var i={mouseup:"touchend",mousedown:"touchstart",mousemove:"touchmove"},u={mouseup:"MSPointerUp",mousedown:"MSPointerDown",mousemove:"MSPointerMove"};t.navigator.msPointerEnabled&&v[n](e,u[r],o),v[n](e,i[r],o),v[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 c(e,n,t){if(!n&&!t)return null;var r,o=e||{},i=o.className;return o.className+=" gu-hide",r=document.elementFromPoint(n,t),o.className=i,r}function a(){return!0}function f(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function l(e,n){-1===e.className.indexOf(" "+n)&&(e.className+=" "+n)}function s(e,n){e.className=e.className.replace(new RegExp(" "+n,"g"),"")}function d(e,n){return"undefined"==typeof n.targetTouches?n[e]:n.targetTouches&&n.targetTouches.length&&n.targetTouches[0][e]||0}var p=e("contra.emitter"),v=e("crossvent");n.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"contra.emitter":3,crossvent:5}],2:[function(e,n){function t(){if(!u){u=!0;for(var e,n=i.length;n;){e=i,i=[];for(var t=-1;++t<n;)e[t]();n=i.length}u=!1}}function r(){}var o=n.exports={},i=[],u=!1;o.nextTick=function(e){i.push(e),u||setTimeout(t,0)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=r,o.addListener=r,o.once=r,o.off=r,o.removeListener=r,o.removeAllListeners=r,o.emit=r,o.binding=function(){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],3:[function(e,n){n.exports=e("./src/contra.emitter.js")},{"./src/contra.emitter.js":4}],4:[function(e,n){(function(e){!function(t,r){"use strict";function o(e,n){return Array.prototype.slice.call(e,n)}function i(e,n,t){e&&c(function(){e.apply(t||null,n||[])})}function u(e,n){var t=n||{},u={};return e===r&&(e={}),e.on=function(n,t){return u[n]?u[n].push(t):u[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 u[n];else if(0===r)u={};else{var o=u[n];if(!o)return e;o.splice(o.indexOf(t),1)}return e},e.emit=function(){var n=o(arguments);return e.emitterSnapshot(n.shift()).apply(this,n)},e.emitterSnapshot=function(n){var r=(u[n]||[]).slice(0);return function(){var c=o(arguments),a=this||e;if("error"===n&&t["throws"]!==!1&&!r.length)throw 1===c.length?c[0]:c;return u[n]=r.filter(function(e){return t.async?i(e,c,a):e.apply(a,c),!e._once}),e}},e}var c,a=""+r,f="function"==typeof setImmediate;c=f?function(e){setImmediate(e)}:typeof e!==a&&e.nextTick?e.nextTick:function(e){setTimeout(e,0)},typeof n!==a&&n.exports?n.exports=u:(t.contra=t.contra||{},t.contra.emitter=u)}(this)}).call(this,e("_process"))},{_process:2}],5:[function(e,n){(function(e){"use strict";function t(e,n,t,r){return e.addEventListener(n,t,r)}function r(e,n,t){return e.attachEvent("on"+n,a(e,n,t))}function o(e,n,t,r){return e.removeEventListener(n,t,r)}function i(e,n,t){return e.detachEvent("on"+n,f(e,n,t))}function u(e,n){var t;s.createEvent?(t=s.createEvent("Event"),t.initEvent(n,!0,!0),e.dispatchEvent(t)):s.createEventObject&&(t=s.createEventObject(),e.fireEvent("on"+n,t))}function c(n,t,r){return function(t){var o=t||e.event;o.target=o.target||o.srcElement,o.preventDefault=o.preventDefault||function(){o.returnValue=!1},o.stopPropagation=o.stopPropagation||function(){o.cancelBubble=!0},r.call(n,o)}}function a(e,n,t){var r=f(e,n,t)||c(e,n,t);return v.push({wrapper:r,element:e,type:n,fn:t}),r}function f(e,n,t){var r=l(e,n,t);if(r){var o=v[r].wrapper;return v.splice(r,1),o}}function l(e,n,t){var r,o;for(r=0;r<v.length;r++)if(o=v[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=document,d=t,p=o,v=[];e.addEventListener||(d=r,p=i),n.exports={add:d,remove:p,fabricate:u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});

@@ -5,6 +5,6 @@ 'use strict';

var crossvent = require('crossvent');
var body = document.body;
var documentElement = document.documentElement;
function dragula (containers, options) {
function dragula (initialContainers, options) {
var body = document.body;
var documentElement = document.documentElement;
var _mirror; // mirror image

@@ -18,2 +18,3 @@ var _source; // source container

var _copy; // item used for copying
var _containers = []; // containers managed by the drake

@@ -40,2 +41,3 @@ var o = options || {};

events();
api.addContainer(initialContainers);

@@ -46,7 +48,15 @@ return api;

return function addOrRemove (all) {
var containers = Array.isArray(all) ? all : [all];
containers.forEach(track);
var changes = Array.isArray(all) ? all : [all];
changes.forEach(track);
if (op === 'add') {
_containers = _containers.concat(changes);
} else {
_containers = _containers.filter(removals);
}
function track (container) {
touchy(container, op, 'mousedown', grab);
}
function removals (container) {
return changes.indexOf(container) === -1;
}
};

@@ -58,3 +68,2 @@ }

touchy(documentElement, op, 'mouseup', release);
api[op + 'Container'](containers);
}

@@ -64,2 +73,3 @@

events(true);
api.removeContainer(_containers);
release({});

@@ -91,6 +101,6 @@ }

if (containers.indexOf(item) !== -1) {
if (_containers.indexOf(item) !== -1) {
return; // don't drag container itself
}
while (containers.indexOf(item.parentElement) === -1) {
while (_containers.indexOf(item.parentElement) === -1) {
if (invalidTarget(item)) {

@@ -234,3 +244,3 @@ return;

function accepted () {
var droppable = containers.indexOf(target) !== -1;
var droppable = _containers.indexOf(target) !== -1;
if (droppable === false) {

@@ -379,5 +389,7 @@ return false;

}
var documentElement = document.documentElement;
if (documentElement.clientHeight) {
return documentElement[scrollProp];
}
var body = document.body;
return body[scrollProp];

@@ -384,0 +396,0 @@ }

{
"name": "dragula",
"version": "1.4.1",
"version": "1.4.2",
"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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc