Comparing version 1.2.1 to 1.2.2
{ | ||
"name": "dragula.js", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Drag and drop so simple it hurts", | ||
@@ -5,0 +5,0 @@ "main": "dist/dragula.js", |
@@ -118,3 +118,3 @@ !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 elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY); | ||
var dropTarget = findDropTarget(elementBehindCursor); | ||
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); | ||
if (dropTarget && (o.copy === false || dropTarget !== _source)) { | ||
@@ -129,3 +129,3 @@ drop(); | ||
function drop () { | ||
if (dropTarget === _source && _initialSibling === _currentSibling) { | ||
if (isInitialPlacement(dropTarget)) { | ||
api.emit('cancel', item, _source); | ||
@@ -162,6 +162,7 @@ } else { | ||
} | ||
if (o.copy === false && reverts && (parent !== _source || _initialSibling !== _currentSibling)) { | ||
var initial = isInitialPlacement(parent); | ||
if (initial === false && o.copy === false && reverts) { | ||
_source.insertBefore(item, _initialSibling); | ||
} | ||
if ((parent === _source && _initialSibling === _currentSibling) || reverts) { | ||
if (initial || reverts) { | ||
api.emit('cancel', item, _source); | ||
@@ -181,3 +182,8 @@ } else { | ||
function findDropTarget (elementBehindCursor) { | ||
function isInitialPlacement (target, s) { | ||
var sibling = s !== void 0 ? s : _currentSibling; | ||
return target === _source && sibling === _initialSibling; | ||
} | ||
function findDropTarget (elementBehindCursor, clientX, clientY) { | ||
var target = elementBehindCursor; | ||
@@ -191,3 +197,13 @@ while (target && !accepted()) { | ||
var droppable = containers.indexOf(target) !== -1; | ||
return droppable && o.accepts(_item, target, _source); | ||
if (droppable === false) { | ||
return false; | ||
} | ||
var immediate = getImmediateChild(target, elementBehindCursor); | ||
var reference = getReference(target, immediate, clientX, clientY); | ||
var initial = isInitialPlacement(target, reference); | ||
if (initial) { | ||
return true; // should always be able to drop it right back where it was | ||
} | ||
return o.accepts(_item, target, _source); | ||
} | ||
@@ -206,3 +222,3 @@ } | ||
var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY); | ||
var dropTarget = findDropTarget(elementBehindCursor); | ||
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); | ||
if (dropTarget === _source && o.copy) { | ||
@@ -581,2 +597,2 @@ return; | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJkcmFndWxhLmpzIiwibm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL3Byb2Nlc3MvYnJvd3Nlci5qcyIsIm5vZGVfbW9kdWxlcy9jb250cmEuZW1pdHRlci9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9jb250cmEuZW1pdHRlci9zcmMvY29udHJhLmVtaXR0ZXIuanMiLCJub2RlX21vZHVsZXMvY3Jvc3N2ZW50L3NyYy9jcm9zc3ZlbnQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0F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2FjaGVbaV07XG4gICAgaWYgKGl0ZW0uZWxlbWVudCA9PT0gZWwgJiYgaXRlbS50eXBlID09PSB0eXBlICYmIGl0ZW0uZm4gPT09IGZuKSB7XG4gICAgICByZXR1cm4gaTtcbiAgICB9XG4gIH1cbn1cblxubW9kdWxlLmV4cG9ydHMgPSB7XG4gIGFkZDogYWRkRXZlbnQsXG4gIHJlbW92ZTogcmVtb3ZlRXZlbnQsXG4gIGZhYnJpY2F0ZTogZmFicmljYXRlRXZlbnRcbn07XG4iXX0= |
@@ -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;"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 f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}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){"use strict";function t(e,n){function t(n){function t(e){s[r](e,"mousedown",m),s[r](e,"touchstart",m)}var r=n?"remove":"add";s[r](v,"mouseup",g),s[r](v,"touchend",g),e.forEach(t)}function d(){t(!0),g({})}function m(n){if(!(0!==n.which&&1!==n.which||n.metaKey||n.ctrlKey||C)){var t=n.target;if(-1===e.indexOf(t)){for(;-1===e.indexOf(t.parentElement);){if(h(t))return;t=t.parentElement}if(!h(t)){var o=t.parentElement,i=A.moves(t,o);if(i){var f=r(t);n.preventDefault(),A.copy?(q=t.cloneNode(!0),c(q,"gu-transit")):c(t,"gu-transit"),L=o,_=t,R=k=u(t),j=a("pageX",n)-f.left,D=a("pageY",n)-f.top,P.emit("drag",_,L),O(),b(n)}}}}}function h(e){return"A"===e.tagName||"BUTTON"===e.tagName}function g(e){function n(){c===L&&R===k?P.emit("cancel",t,L):P.emit("drop",t,c,L),w()}if(C){var t=q||_,r=a("clientX",e),i=a("clientY",e),u=o(B,r,i),c=x(u);!c||A.copy!==!1&&c===L?A.removeOnSpill?y():E():n()}}function y(){if(C){var e=q||_,n=e.parentElement;n&&n.removeChild(e),P.emit(A.copy?"cancel":"remove",e,n),w()}}function E(e){if(C){var n=arguments.length>0?e:A.revertOnSpill,t=q||_,r=t.parentElement;r===L&&A.copy&&r.removeChild(q),A.copy!==!1||!n||r===L&&R===k||L.insertBefore(t,R),r===L&&R===k||n?P.emit("cancel",t,L):P.emit("drop",t,r,L),w()}}function w(){var e=q||_;N(),f(e,"gu-transit"),L=_=q=R=k=null}function x(n){function t(){var n=-1!==e.indexOf(r);return n&&A.accepts(_,r,L)}for(var r=n;r&&!t();)r=r.parentElement;return r}function b(e){var n=a("clientX",e),t=a("clientY",e),r=n-j,i=t-D;B.style.left=r+"px",B.style.top=i+"px";var c=o(B,n,t),f=x(c);if(f!==L||!A.copy){var l=q||_,s=T(f,c);if(null!==s){var p=S(f,s,n,t);(null===p||p!==l&&p!==u(l))&&(k=p,f.insertBefore(l,p),P.emit("shadow",l,f))}}}function O(){var e=_.getBoundingClientRect();C=!0,B=_.cloneNode(!0),B.style.width=e.width+"px",B.style.height=e.height+"px",f(B,"gu-transit"),c(B," gu-mirror"),p.appendChild(B),s.add(v,"mousemove",b),s.add(v,"touchmove",b),c(p,"gu-unselectable")}function N(){B&&(f(p,"gu-unselectable"),s.remove(v,"mousemove",b),s.remove(v,"touchmove",b),B.parentElement.removeChild(B),B=null,C=!1)}function T(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===v?null:t}function S(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(),f&&i.left>t)return o;if(!f&&i.top>r)return o}return null}function i(){var e=n.getBoundingClientRect();return c(f?t>e.left+e.width/2:r>e.top+e.height/2)}function c(e){return e?u(n):n}var f="horizontal"===A.direction,a=n!==e?i():o();return a}var C,B,L,_,j,D,R,k,q,A=n||{};void 0===A.moves&&(A.moves=i),void 0===A.accepts&&(A.accepts=i),void 0===A.copy&&(A.copy=!1),void 0===A.revertOnSpill&&(A.revertOnSpill=!1),void 0===A.removeOnSpill&&(A.removeOnSpill=!1),void 0===A.direction&&(A.direction="vertical");var P=l({cancel:E,remove:y,destroy:d});return t(),P}function r(e){var n=e.getBoundingClientRect();return{left:n.left+p.scrollLeft,top:n.top+p.scrollTop}}function o(e,n,t){if(!n&&!t)return null;var r=e.className;e.className+=" gu-hide";var o=document.elementFromPoint(n,t);return e.className=r,o}function i(){return!0}function u(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function c(e,n){-1===e.className.indexOf(" "+n)&&(e.className+=" "+n)}function f(e,n){e.className=e.className.replace(new RegExp(" "+n,"g"),"")}function a(e,n){return"undefined"==typeof n.targetTouches?n[e]:n.targetTouches&&n.targetTouches.length&&n.targetTouches[0][e]||0}var l=e("contra.emitter"),s=e("crossvent"),p=document.body,v=document.documentElement;n.exports=t},{"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),f=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,f):e.apply(f,c),!e._once}),e}},e}var c,f=""+r,a="function"==typeof setImmediate;c=a?function(e){setImmediate(e)}:typeof e!==f&&e.nextTick?e.nextTick:function(e){setTimeout(e,0)},typeof n!==f&&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,f(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,a(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 f(e,n,t){var r=a(e,n,t)||c(e,n,t);return d.push({wrapper:r,element:e,type:n,fn:t}),r}function a(e,n,t){var r=l(e,n,t);if(r){var o=d[r].wrapper;return d.splice(r,1),o}}function l(e,n,t){var r,o;for(r=0;r<d.length;r++)if(o=d[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=document,p=t,v=o,d=[];e.addEventListener||(p=r,v=i),n.exports={add:p,remove:v,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){"use strict";function t(e,n){function t(n){function t(e){s[r](e,"mousedown",m),s[r](e,"touchstart",m)}var r=n?"remove":"add";s[r](v,"mouseup",g),s[r](v,"touchend",g),e.forEach(t)}function d(){t(!0),g({})}function m(n){if(!(0!==n.which&&1!==n.which||n.metaKey||n.ctrlKey||B)){var t=n.target;if(-1===e.indexOf(t)){for(;-1===e.indexOf(t.parentElement);){if(h(t))return;t=t.parentElement}if(!h(t)){var o=t.parentElement,i=P.moves(t,o);if(i){var a=r(t);n.preventDefault(),P.copy?(A=t.cloneNode(!0),c(A,"gu-transit")):c(t,"gu-transit"),_=o,j=t,k=q=u(t),D=f("pageX",n)-a.left,R=f("pageY",n)-a.top,U.emit("drag",j,_),N(),O(n)}}}}}function h(e){return"A"===e.tagName||"BUTTON"===e.tagName}function g(e){function n(){x(c)?U.emit("cancel",t,_):U.emit("drop",t,c,_),w()}if(B){var t=A||j,r=f("clientX",e),i=f("clientY",e),u=o(L,r,i),c=b(u,r,i);!c||P.copy!==!1&&c===_?P.removeOnSpill?y():E():n()}}function y(){if(B){var e=A||j,n=e.parentElement;n&&n.removeChild(e),U.emit(P.copy?"cancel":"remove",e,n),w()}}function E(e){if(B){var n=arguments.length>0?e:P.revertOnSpill,t=A||j,r=t.parentElement;r===_&&P.copy&&r.removeChild(A);var o=x(r);o===!1&&P.copy===!1&&n&&_.insertBefore(t,k),o||n?U.emit("cancel",t,_):U.emit("drop",t,r,_),w()}}function w(){var e=A||j;T(),a(e,"gu-transit"),_=j=A=k=q=null}function x(e,n){var t=void 0!==n?n:q;return e===_&&t===k}function b(n,t,r){function o(){var o=-1!==e.indexOf(i);if(o===!1)return!1;var u=S(i,n),c=C(i,u,t,r),a=x(i,c);return a?!0:P.accepts(j,i,_)}for(var i=n;i&&!o();)i=i.parentElement;return i}function O(e){var n=f("clientX",e),t=f("clientY",e),r=n-D,i=t-R;L.style.left=r+"px",L.style.top=i+"px";var c=o(L,n,t),a=b(c,n,t);if(a!==_||!P.copy){var l=A||j,s=S(a,c);if(null!==s){var p=C(a,s,n,t);(null===p||p!==l&&p!==u(l))&&(q=p,a.insertBefore(l,p),U.emit("shadow",l,a))}}}function N(){var e=j.getBoundingClientRect();B=!0,L=j.cloneNode(!0),L.style.width=e.width+"px",L.style.height=e.height+"px",a(L,"gu-transit"),c(L," gu-mirror"),p.appendChild(L),s.add(v,"mousemove",O),s.add(v,"touchmove",O),c(p,"gu-unselectable")}function T(){L&&(a(p,"gu-unselectable"),s.remove(v,"mousemove",O),s.remove(v,"touchmove",O),L.parentElement.removeChild(L),L=null,B=!1)}function S(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===v?null:t}function C(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 c(a?t>e.left+e.width/2:r>e.top+e.height/2)}function c(e){return e?u(n):n}var a="horizontal"===P.direction,f=n!==e?i():o();return f}var B,L,_,j,D,R,k,q,A,P=n||{};void 0===P.moves&&(P.moves=i),void 0===P.accepts&&(P.accepts=i),void 0===P.copy&&(P.copy=!1),void 0===P.revertOnSpill&&(P.revertOnSpill=!1),void 0===P.removeOnSpill&&(P.removeOnSpill=!1),void 0===P.direction&&(P.direction="vertical");var U=l({cancel:E,remove:y,destroy:d});return t(),U}function r(e){var n=e.getBoundingClientRect();return{left:n.left+p.scrollLeft,top:n.top+p.scrollTop}}function o(e,n,t){if(!n&&!t)return null;var r=e.className;e.className+=" gu-hide";var o=document.elementFromPoint(n,t);return e.className=r,o}function i(){return!0}function u(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function c(e,n){-1===e.className.indexOf(" "+n)&&(e.className+=" "+n)}function a(e,n){e.className=e.className.replace(new RegExp(" "+n,"g"),"")}function f(e,n){return"undefined"==typeof n.targetTouches?n[e]:n.targetTouches&&n.targetTouches.length&&n.targetTouches[0][e]||0}var l=e("contra.emitter"),s=e("crossvent"),p=document.body,v=document.documentElement;n.exports=t},{"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 d.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=d[r].wrapper;return d.splice(r,1),o}}function l(e,n,t){var r,o;for(r=0;r<d.length;r++)if(o=d[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=document,p=t,v=o,d=[];e.addEventListener||(p=r,v=i),n.exports={add:p,remove:v,fabricate:u}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}); |
@@ -117,3 +117,3 @@ 'use strict'; | ||
var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY); | ||
var dropTarget = findDropTarget(elementBehindCursor); | ||
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); | ||
if (dropTarget && (o.copy === false || dropTarget !== _source)) { | ||
@@ -128,3 +128,3 @@ drop(); | ||
function drop () { | ||
if (dropTarget === _source && _initialSibling === _currentSibling) { | ||
if (isInitialPlacement(dropTarget)) { | ||
api.emit('cancel', item, _source); | ||
@@ -161,6 +161,7 @@ } else { | ||
} | ||
if (o.copy === false && reverts && (parent !== _source || _initialSibling !== _currentSibling)) { | ||
var initial = isInitialPlacement(parent); | ||
if (initial === false && o.copy === false && reverts) { | ||
_source.insertBefore(item, _initialSibling); | ||
} | ||
if ((parent === _source && _initialSibling === _currentSibling) || reverts) { | ||
if (initial || reverts) { | ||
api.emit('cancel', item, _source); | ||
@@ -180,3 +181,8 @@ } else { | ||
function findDropTarget (elementBehindCursor) { | ||
function isInitialPlacement (target, s) { | ||
var sibling = s !== void 0 ? s : _currentSibling; | ||
return target === _source && sibling === _initialSibling; | ||
} | ||
function findDropTarget (elementBehindCursor, clientX, clientY) { | ||
var target = elementBehindCursor; | ||
@@ -190,3 +196,13 @@ while (target && !accepted()) { | ||
var droppable = containers.indexOf(target) !== -1; | ||
return droppable && o.accepts(_item, target, _source); | ||
if (droppable === false) { | ||
return false; | ||
} | ||
var immediate = getImmediateChild(target, elementBehindCursor); | ||
var reference = getReference(target, immediate, clientX, clientY); | ||
var initial = isInitialPlacement(target, reference); | ||
if (initial) { | ||
return true; // should always be able to drop it right back where it was | ||
} | ||
return o.accepts(_item, target, _source); | ||
} | ||
@@ -205,3 +221,3 @@ } | ||
var elementBehindCursor = getElementBehindPoint(_mirror, clientX, clientY); | ||
var dropTarget = findDropTarget(elementBehindCursor); | ||
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); | ||
if (dropTarget === _source && o.copy) { | ||
@@ -208,0 +224,0 @@ return; |
{ | ||
"name": "dragula", | ||
"version": "1.2.1", | ||
"version": "1.2.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
427472
1075