Comparing version 3.0.7 to 3.1.0
{ | ||
"name": "dragula.js", | ||
"version": "3.0.7", | ||
"version": "3.1.0", | ||
"description": "Drag and drop so simple it hurts", | ||
@@ -5,0 +5,0 @@ "main": [ |
@@ -147,6 +147,7 @@ (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){ | ||
function startBecauseMouseMoved (e) { | ||
var grabbed = _grabbed; // call to end() unsets _grabbed | ||
eventualMovements(true); | ||
movements(); | ||
end(); | ||
start(_grabbed); | ||
start(grabbed); | ||
@@ -206,3 +207,3 @@ var offset = getOffset(_item); | ||
function start (context) { | ||
if (o.copy) { | ||
if (isCopy(context.item, context.source)) { | ||
_copy = context.item.cloneNode(true); | ||
@@ -249,3 +250,3 @@ drake.emit('cloned', _copy, context.item, 'copy'); | ||
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); | ||
if (dropTarget && (o.copy === false || dropTarget !== _source)) { | ||
if (dropTarget && (!_copy || dropTarget !== _source)) { | ||
drop(item, dropTarget); | ||
@@ -277,3 +278,3 @@ } else if (o.removeOnSpill) { | ||
} | ||
drake.emit(o.copy ? 'cancel' : 'remove', item, parent); | ||
drake.emit(_copy ? 'cancel' : 'remove', item, parent); | ||
cleanup(); | ||
@@ -289,7 +290,7 @@ } | ||
var parent = item.parentElement; | ||
if (parent === _source && o.copy) { | ||
if (parent === _source && _copy) { | ||
parent.removeChild(_copy); | ||
} | ||
var initial = isInitialPlacement(parent); | ||
if (initial === false && o.copy === false && reverts) { | ||
if (initial === false && !_copy && reverts) { | ||
_source.insertBefore(item, _initialSibling); | ||
@@ -379,3 +380,3 @@ } | ||
} | ||
if (dropTarget === _source && o.copy) { | ||
if (dropTarget === _source && _copy) { | ||
if (item.parentElement) { | ||
@@ -390,7 +391,7 @@ item.parentElement.removeChild(item); | ||
reference = getReference(dropTarget, immediate, clientX, clientY); | ||
} else if (o.revertOnSpill === true && !o.copy) { | ||
} else if (o.revertOnSpill === true && !_copy) { | ||
reference = _initialSibling; | ||
dropTarget = _source; | ||
} else { | ||
if (o.copy && item.parentElement) { | ||
if (_copy && item.parentElement) { | ||
item.parentElement.removeChild(item); | ||
@@ -490,2 +491,6 @@ } | ||
} | ||
function isCopy (item, container) { | ||
return typeof o.copy === 'boolean' ? o.copy : o.copy(item, container); | ||
} | ||
} | ||
@@ -543,2 +548,4 @@ | ||
function always () { return true; } | ||
function getRectWidth (rect) { return rect.width || (rect.right - rect.left); } | ||
function getRectHeight (rect) { return rect.height || (rect.bottom - rect.top); } | ||
@@ -581,10 +588,2 @@ function nextEl (el) { | ||
function getRectWidth (rect) { | ||
return rect.width || (rect.right - rect.left); | ||
} | ||
function getRectHeight (rect) { | ||
return rect.height || (rect.bottom - rect.top); | ||
} | ||
module.exports = dragula; | ||
@@ -853,2 +852,2 @@ | ||
}); | ||
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJjbGFzc2VzLmpzIiwiZHJhZ3VsYS5qcyIsIm5vZGVfbW9kdWxlcy9jb250cmEvZGVib3VuY2UuanMiLCJub2RlX21vZHVsZXMvY29udHJh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iAoaXRlbS5lbGVtZW50ID09PSBlbCAmJiBpdGVtLnR5cGUgPT09IHR5cGUgJiYgaXRlbS5mbiA9PT0gZm4pIHtcbiAgICAgIHJldHVybiBpO1xuICAgIH1cbiAgfVxufVxuIiwiJ3VzZSBzdHJpY3QnO1xuXG52YXIgZXZlbnRtYXAgPSBbXTtcbnZhciBldmVudG5hbWUgPSAnJztcbnZhciByb24gPSAvXm9uLztcblxuZm9yIChldmVudG5hbWUgaW4gZ2xvYmFsKSB7XG4gIGlmIChyb24udGVzdChldmVudG5hbWUpKSB7XG4gICAgZXZlbnRtYXAucHVzaChldmVudG5hbWUuc2xpY2UoMikpO1xuICB9XG59XG5cbm1vZHVsZS5leHBvcnRzID0gZXZlbnRtYXA7XG4iXX0= | ||
//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJjbGFzc2VzLmpzIiwiZHJhZ3VsYS5qcyIsIm5vZGVfbW9kdWxlcy9jb250cmEvZGVib3VuY2UuanMiLCJub2RlX21vZHVsZXMvY29udHJhL2VtaXR0ZXIuanMiLCJub2RlX21vZHVsZXMvY29udHJhL25vZGVfbW9kdWxlcy9hdG9hL2F0b2EuanMiLCJub2RlX21vZHVsZXMvY29udHJhL25vZGVfbW9kdWxlcy90aWNreS90aWNreS1icm93c2VyLmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9ub2RlX21vZHVsZXMvY3VzdG9tLWV2ZW50L2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9zcmMvY3Jvc3N2ZW50LmpzIiwibm9kZV9tb2R1bGVzL2Nyb3NzdmVudC9zcmMvZXZlbnRtYXAuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QU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UgPSAnJztcbnZhciByb24gPSAvXm9uLztcblxuZm9yIChldmVudG5hbWUgaW4gZ2xvYmFsKSB7XG4gIGlmIChyb24udGVzdChldmVudG5hbWUpKSB7XG4gICAgZXZlbnRtYXAucHVzaChldmVudG5hbWUuc2xpY2UoMikpO1xuICB9XG59XG5cbm1vZHVsZS5leHBvcnRzID0gZXZlbnRtYXA7XG4iXX0= |
@@ -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 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,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!==te.containers.indexOf(e)||ne.isContainer(e)}function r(e){var n=e?"remove":"add";o(Z,n,"mousedown",E),o(Z,n,"mouseup",T)}function u(e){var n=e?"remove":"add";o(Z,n,"mousemove",b)}function d(e){var n=e?"remove":"add";o(Z,n,"selectstart",y),o(Z,n,"click",y)}function g(){r(!0),T({})}function y(e){Q&&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&&(Q=r,u(),"mousedown"===e.type&&(e.preventDefault(),("INPUT"===t.tagName||"TEXTAREA"===t.tagName)&&t.focus()))}}function b(e){u(!0),d(),N(),C(Q);var n=i(K);z=s("pageX",e)-n.left,H=s("pageY",e)-n.top,h.add(G||K,"gu-transit"),j(),A(e)}function w(e){if(!(te.dragging&&_||t(e))){for(var n=e;e.parentElement&&t(e.parentElement)===!1;){if(ne.invalid(e,n))return;if(e=e.parentElement,!e)return}var r=e.parentElement;if(r&&!ne.invalid(e,n)){var o=ne.moves(e,r,n);if(o)return{item:e,source:r}}}}function x(e){var n=w(e);n&&C(n)}function C(e){ne.copy&&(G=e.item.cloneNode(!0),te.emit("cloned",G,e.item,"copy")),F=e.source,K=e.item,V=$=l(e.item),te.dragging=!0,te.emit("drag",K,F)}function O(){return!1}function N(){if(te.dragging){var e=G||K;B(e,e.parentElement)}}function S(){Q=!1,u(!0),d(!0)}function T(e){if(S(),te.dragging){var n=G||K,t=s("clientX",e),r=s("clientY",e),o=a(_,t,r),i=Y(o,t,r);!i||ne.copy!==!1&&i===F?ne.removeOnSpill?D():P():B(n,i)}}function B(e,n){R(n)?te.emit("cancel",e,F):te.emit("drop",e,n,F),X()}function D(){if(te.dragging){var e=G||K,n=e.parentElement;n&&n.removeChild(e),te.emit(ne.copy?"cancel":"remove",e,n),X()}}function P(e){if(te.dragging){var n=arguments.length>0?e:ne.revertOnSpill,t=G||K,r=t.parentElement;r===F&&ne.copy&&r.removeChild(G);var o=R(r);o===!1&&ne.copy===!1&&n&&F.insertBefore(t,V),o||n?te.emit("cancel",t,F):te.emit("drop",t,r,F),X()}}function X(){var e=G||K;S(),k(),e&&h.rm(e,"gu-transit"),J&&clearTimeout(J),te.dragging=!1,te.emit("out",e,ee,F),te.emit("dragend",e),F=K=G=V=$=J=ee=null}function R(e,n){var t;return t=void 0!==n?n:_?$:l(G||K),e===F&&t===V}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:ne.accepts(K,i,F,a)}for(var i=e;i&&!o();)i=i.parentElement;return i}function A(e){function n(e){te.emit(e,f,ee,F)}function t(){m&&n("over")}function r(){ee&&n("out")}if(_){e.preventDefault();var o=s("clientX",e),i=s("clientY",e),u=o-z,c=i-H;_.style.left=u+"px",_.style.top=c+"px";var f=G||K,d=a(_,o,i),v=Y(d,o,i),m=null!==v&&v!==ee;if((m||null===v)&&(r(),ee=v,t()),v===F&&ne.copy)return void(f.parentElement&&f.parentElement.removeChild(f));var p,g=q(v,d);if(null!==g)p=I(v,g,o,i);else{if(ne.revertOnSpill!==!0||ne.copy)return void(ne.copy&&f.parentElement&&f.parentElement.removeChild(f));p=V,v=F}(null===p||p!==f&&p!==l(f)&&p!==$)&&($=p,v.insertBefore(f,p),te.emit("shadow",f,v))}}function L(e){h.rm(e,"gu-hide")}function M(e){te.dragging&&h.add(e,"gu-hide")}function j(){if(!_){var e=K.getBoundingClientRect();_=K.cloneNode(!0),_.style.width=v(e)+"px",_.style.height=m(e)+"px",h.rm(_,"gu-transit"),h.add(_,"gu-mirror"),ne.mirrorContainer.appendChild(_),o(Z,"add","mousemove",A),h.add(ne.mirrorContainer,"gu-unselectable"),te.emit("cloned",_,K,"mirror")}}function k(){_&&(h.rm(ne.mirrorContainer,"gu-unselectable"),o(Z,"remove","mousemove",A),_.parentElement.removeChild(_),_=null)}function q(e,n){for(var t=n;t!==e&&t.parentElement!==e;)t=t.parentElement;return t===Z?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+v(e)/2:r>e.top+m(e)/2)}function u(e){return e?l(n):n}var a="horizontal"===ne.direction,c=n!==e?i():o();return c}var U=arguments.length;1===U&&Array.isArray(e)===!1&&(n=e,e=[]);var _,F,K,z,H,V,$,G,J,Q,W=document.body,Z=document.documentElement,ee=null,ne=n||{};void 0===ne.moves&&(ne.moves=f),void 0===ne.accepts&&(ne.accepts=f),void 0===ne.invalid&&(ne.invalid=O),void 0===ne.containers&&(ne.containers=e||[]),void 0===ne.isContainer&&(ne.isContainer=c),void 0===ne.copy&&(ne.copy=!1),void 0===ne.revertOnSpill&&(ne.revertOnSpill=!1),void 0===ne.removeOnSpill&&(ne.removeOnSpill=!1),void 0===ne.direction&&(ne.direction="vertical"),void 0===ne.mirrorContainer&&(ne.mirrorContainer=W);var te=p({containers:ne.containers,start:x,end:N,cancel:P,remove:D,destroy:g,dragging:!1});return ne.removeOnSpill===!0&&te.on("over",L).on("out",M),r(),te}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 f(){return!0}function l(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function d(e){return e.targetTouches&&e.targetTouches.length?e.targetTouches[0]:e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e}function s(e,n){var t=d(n),r={pageX:"clientX",pageY:"clientY"};return e in r&&!(e in t)&&r[e]in t&&(e=r[e]),t[e]}function v(e){return e.width||e.right-e.left}function m(e){return e.height||e.bottom-e.top}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,f(e,n,t))}function i(e,n,t,r){return e.removeEventListener(n,t,r)}function u(e,n,t){var r=l(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 f(e,n,t){var r=l(e,n,t)||c(e,n,t);return h.push({wrapper:r,element:e,type:n,fn:t}),r}function l(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 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,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(),N(),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);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 O(){return!1}function N(){if(re.dragging){var e=J||z;B(e,e.parentElement)}}function S(){W=!1,u(!0),v(!0)}function T(e){if(S(),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&&i===K?te.removeOnSpill?D():P():B(n,i)}}function B(e,n){R(n)?re.emit("cancel",e,K):re.emit("drop",e,n,K),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;S(),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,f,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 f=J||z,l=a(F,o,i),d=Y(l,o,i),v=null!==d&&d!==ne;if((v||null===d)&&(r(),ne=d,t()),d===K&&J)return void(f.parentElement&&f.parentElement.removeChild(f));var p,g=q(d,l);if(null!==g)p=I(d,g,o,i);else{if(te.revertOnSpill!==!0||J)return void(J&&f.parentElement&&f.parentElement.removeChild(f));p=$,d=K}(null===p||p!==f&&p!==s(f)&&p!==G)&&(G=p,d.insertBefore(f,p),re.emit("shadow",f,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=l(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+l(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=f),void 0===te.accepts&&(te.accepts=f),void 0===te.invalid&&(te.invalid=O),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);var re=p({containers:te.containers,start:x,end:N,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 f(){return!0}function l(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,f(e,n,t))}function i(e,n,t,r){return e.removeEventListener(n,t,r)}function u(e,n,t){var r=l(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 f(e,n,t){var r=l(e,n,t)||c(e,n,t);return h.push({wrapper:r,element:e,type:n,fn:t}),r}function l(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)}); |
@@ -110,6 +110,7 @@ 'use strict'; | ||
function startBecauseMouseMoved (e) { | ||
var grabbed = _grabbed; // call to end() unsets _grabbed | ||
eventualMovements(true); | ||
movements(); | ||
end(); | ||
start(_grabbed); | ||
start(grabbed); | ||
@@ -169,3 +170,3 @@ var offset = getOffset(_item); | ||
function start (context) { | ||
if (o.copy) { | ||
if (isCopy(context.item, context.source)) { | ||
_copy = context.item.cloneNode(true); | ||
@@ -212,3 +213,3 @@ drake.emit('cloned', _copy, context.item, 'copy'); | ||
var dropTarget = findDropTarget(elementBehindCursor, clientX, clientY); | ||
if (dropTarget && (o.copy === false || dropTarget !== _source)) { | ||
if (dropTarget && (!_copy || dropTarget !== _source)) { | ||
drop(item, dropTarget); | ||
@@ -240,3 +241,3 @@ } else if (o.removeOnSpill) { | ||
} | ||
drake.emit(o.copy ? 'cancel' : 'remove', item, parent); | ||
drake.emit(_copy ? 'cancel' : 'remove', item, parent); | ||
cleanup(); | ||
@@ -252,7 +253,7 @@ } | ||
var parent = item.parentElement; | ||
if (parent === _source && o.copy) { | ||
if (parent === _source && _copy) { | ||
parent.removeChild(_copy); | ||
} | ||
var initial = isInitialPlacement(parent); | ||
if (initial === false && o.copy === false && reverts) { | ||
if (initial === false && !_copy && reverts) { | ||
_source.insertBefore(item, _initialSibling); | ||
@@ -342,3 +343,3 @@ } | ||
} | ||
if (dropTarget === _source && o.copy) { | ||
if (dropTarget === _source && _copy) { | ||
if (item.parentElement) { | ||
@@ -353,7 +354,7 @@ item.parentElement.removeChild(item); | ||
reference = getReference(dropTarget, immediate, clientX, clientY); | ||
} else if (o.revertOnSpill === true && !o.copy) { | ||
} else if (o.revertOnSpill === true && !_copy) { | ||
reference = _initialSibling; | ||
dropTarget = _source; | ||
} else { | ||
if (o.copy && item.parentElement) { | ||
if (_copy && item.parentElement) { | ||
item.parentElement.removeChild(item); | ||
@@ -453,2 +454,6 @@ } | ||
} | ||
function isCopy (item, container) { | ||
return typeof o.copy === 'boolean' ? o.copy : o.copy(item, container); | ||
} | ||
} | ||
@@ -506,2 +511,4 @@ | ||
function always () { return true; } | ||
function getRectWidth (rect) { return rect.width || (rect.right - rect.left); } | ||
function getRectHeight (rect) { return rect.height || (rect.bottom - rect.top); } | ||
@@ -544,10 +551,2 @@ function nextEl (el) { | ||
function getRectWidth (rect) { | ||
return rect.width || (rect.right - rect.left); | ||
} | ||
function getRectHeight (rect) { | ||
return rect.height || (rect.bottom - rect.top); | ||
} | ||
module.exports = dragula; |
@@ -5,6 +5,7 @@ (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 sortable = $('sortable'); | ||
dragula([$('left1'), $('right1')]); | ||
dragula([$('left2'), $('right2')], { copy: true }); | ||
dragula([$('left3'), $('right3')]) | ||
dragula([$('left-defaults'), $('right-defaults')]); | ||
dragula([$('left-copy'), $('right-copy')], { copy: true }); | ||
dragula([$('left-events'), $('right-events')]) | ||
.on('drag', function (el) { | ||
@@ -22,4 +23,4 @@ el.className = el.className.replace('ex-moved', ''); | ||
}); | ||
dragula([$('left4'), $('right4')], { revertOnSpill: true }); | ||
dragula([$('left5'), $('right5')], { | ||
dragula([$('left-rollbacks'), $('right-rollbacks')], { revertOnSpill: true }); | ||
dragula([$('left-lovehandles'), $('right-lovehandles')], { | ||
moves: function (el, container, handle) { | ||
@@ -30,13 +31,19 @@ return handle.className === 'handle'; | ||
dragula([$('left6'), $('right6')], { removeOnSpill: true }); | ||
dragula([$('left-rm-spill'), $('right-rm-spill')], { removeOnSpill: true }); | ||
dragula([$('left-copy-1tomany'), $('right-copy-1tomany')], { | ||
copy: function (el, source) { | ||
return source === $('left-copy-1tomany') | ||
}, | ||
accepts: function (el, target) { | ||
return target !== $('left-copy-1tomany') | ||
} | ||
}); | ||
var single1 = $('single1'); | ||
dragula([sortable]); | ||
dragula([single1]); | ||
crossvent.add(sortable, 'click', clickHandler); | ||
crossvent.add(single1, 'click', clickHandler); | ||
function clickHandler (e) { | ||
var target = e.target; | ||
if (target === single1) { | ||
if (target === sortable) { | ||
return; | ||
@@ -115,5 +122,2 @@ } | ||
var doc = global.document; | ||
if (!doc) { | ||
return; | ||
} | ||
var addEvent = addEventEasy; | ||
@@ -128,2 +132,8 @@ var removeEvent = removeEventEasy; | ||
module.exports = { | ||
add: addEvent, | ||
remove: removeEvent, | ||
fabricate: fabricateEvent | ||
}; | ||
function addEventEasy (el, type, fn, capturing) { | ||
@@ -211,8 +221,2 @@ return el.addEventListener(type, fn, capturing); | ||
module.exports = { | ||
add: addEvent, | ||
remove: removeEvent, | ||
fabricate: fabricateEvent | ||
}; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
@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7IGkgPCBoYXJkQ2FjaGUubGVuZ3RoOyBpKyspIHtcbiAgICBpdGVtID0gaGFyZENhY2hlW2ldO1xuICAgIGlmIChpdGVtLmVsZW1lbnQgPT09IGVsICYmIGl0ZW0udHlwZSA9PT0gdHlwZSAmJiBpdGVtLmZuID09PSBmbikge1xuICAgICAgcmV0dXJuIGk7XG4gICAgfVxuICB9XG59XG4iLCIndXNlIHN0cmljdCc7XG5cbnZhciBldmVudG1hcCA9IFtdO1xudmFyIGV2ZW50bmFtZSA9ICcnO1xudmFyIHJvbiA9IC9eb24vO1xuXG5mb3IgKGV2ZW50bmFtZSBpbiBnbG9iYWwpIHtcbiAgaWYgKHJvbi50ZXN0KGV2ZW50bmFtZSkpIHtcbiAgICBldmVudG1hcC5wdXNoKGV2ZW50bmFtZS5zbGljZSgyKSk7XG4gIH1cbn1cblxubW9kdWxlLmV4cG9ydHMgPSBldmVudG1hcDtcbiJdfQ== |
'use strict'; | ||
var crossvent = require('crossvent'); | ||
var sortable = $('sortable'); | ||
dragula([$('left1'), $('right1')]); | ||
dragula([$('left2'), $('right2')], { copy: true }); | ||
dragula([$('left3'), $('right3')]) | ||
dragula([$('left-defaults'), $('right-defaults')]); | ||
dragula([$('left-copy'), $('right-copy')], { copy: true }); | ||
dragula([$('left-events'), $('right-events')]) | ||
.on('drag', function (el) { | ||
@@ -20,4 +21,4 @@ el.className = el.className.replace('ex-moved', ''); | ||
}); | ||
dragula([$('left4'), $('right4')], { revertOnSpill: true }); | ||
dragula([$('left5'), $('right5')], { | ||
dragula([$('left-rollbacks'), $('right-rollbacks')], { revertOnSpill: true }); | ||
dragula([$('left-lovehandles'), $('right-lovehandles')], { | ||
moves: function (el, container, handle) { | ||
@@ -28,13 +29,19 @@ return handle.className === 'handle'; | ||
dragula([$('left6'), $('right6')], { removeOnSpill: true }); | ||
dragula([$('left-rm-spill'), $('right-rm-spill')], { removeOnSpill: true }); | ||
dragula([$('left-copy-1tomany'), $('right-copy-1tomany')], { | ||
copy: function (el, source) { | ||
return source === $('left-copy-1tomany') | ||
}, | ||
accepts: function (el, target) { | ||
return target !== $('left-copy-1tomany') | ||
} | ||
}); | ||
var single1 = $('single1'); | ||
dragula([sortable]); | ||
dragula([single1]); | ||
crossvent.add(sortable, 'click', clickHandler); | ||
crossvent.add(single1, 'click', clickHandler); | ||
function clickHandler (e) { | ||
var target = e.target; | ||
if (target === single1) { | ||
if (target === sortable) { | ||
return; | ||
@@ -41,0 +48,0 @@ } |
{ | ||
"name": "dragula", | ||
"version": "3.0.7", | ||
"version": "3.1.0", | ||
"description": "Drag and drop so simple it hurts", | ||
@@ -17,3 +17,3 @@ "main": "dragula.js", | ||
"sync": "git checkout gh-pages ; git merge master ; git push ; git checkout master", | ||
"test": "jshint . --reporter node_modules/jshint-stylish/index.js && browserify test/drag.js | testron", | ||
"test": "jshint . --reporter node_modules/jshint-stylish/index.js && browserify test/*.js | testron", | ||
"test-watch": "hihat test/*.js -p tap-dev-tool" | ||
@@ -20,0 +20,0 @@ }, |
@@ -10,2 +10,4 @@ 'use strict'; | ||
testCase('works for wheel clicks', { which: 1 }); | ||
testCase('works when clicking buttons by default', { which: 0 }, { tag: 'button', passes: true }); | ||
testCase('works when clicking anchors by default', { which: 0 }, { tag: 'a', passes: true }); | ||
testCase('fails for right clicks', { which: 2 }, { passes: false }); | ||
@@ -15,4 +17,2 @@ testCase('fails for meta-clicks', { which: 0, metaKey: true }, { passes: false }); | ||
testCase('fails when clicking containers', { which: 0 }, { containerClick: true, passes: false }); | ||
testCase('fails when clicking buttons by default', { which: 0 }, { tag: 'button', passes: false }); | ||
testCase('fails when clicking anchors by default', { which: 0 }, { tag: 'a', passes: false }); | ||
testCase('fails whenever invalid returns true', { which: 0 }, { passes: false, dragulaOpts: { invalid: always } }); | ||
@@ -32,10 +32,10 @@ testCase('fails whenever moves returns false', { which: 0 }, { passes: false, dragulaOpts: { moves: never } }); | ||
events.raise(o.containerClick ? div : item, 'mousedown', eventOptions); | ||
if (passes) { events.raise(o.containerClick ? div : item, 'mousemove'); } | ||
events.raise(o.containerClick ? div : item, 'mousemove'); | ||
st.plan(passes ? 4 : 1); | ||
st.equal(drake.dragging, passes, 'final state is drake is ' + (passes ? '' : 'not ') + 'dragging'); | ||
st.equal(drake.dragging, passes, desc + ': final state is drake is ' + (passes ? '' : 'not ') + 'dragging'); | ||
st.end(); | ||
function drag (target, container) { | ||
st[passes ? 'pass' : 'fail']('drag event was emitted synchronously'); | ||
st.equal(target, item, 'first argument is selected item'); | ||
st.equal(container, div, 'second argument is container'); | ||
st[passes ? 'pass' : 'fail'](desc + ': drag event was emitted synchronously'); | ||
st.equal(target, item, desc + ': first argument is selected item'); | ||
st.equal(container, div, desc + ': second argument is container'); | ||
} | ||
@@ -46,3 +46,3 @@ }); | ||
test('when already dragging, ends (cancels) previous drag', function (t) { | ||
test('when already dragging, mousedown/mousemove ends (cancels) previous drag', function (t) { | ||
var div = document.createElement('div'); | ||
@@ -235,3 +235,27 @@ var item1 = document.createElement('div'); | ||
test('when drag begins, check for copy option', function (t) { | ||
var div = document.createElement('div'); | ||
var item = document.createElement('div'); | ||
item.className = 'copyable'; | ||
div.className = 'contains'; | ||
var drake = dragula([div], { | ||
copy: checkCondition | ||
}); | ||
item.innerHTML = '<em>the force is <strong>with this one</strong></em>'; | ||
div.appendChild(item); | ||
document.body.appendChild(div); | ||
events.raise(item, 'mousedown', { which: 0 }); | ||
events.raise(item, 'mousemove', { which: 0 }); | ||
events.raise(item, 'mousemove', { which: 0 }); // ensure the copy method condition is only asserted once | ||
t.plan(2); | ||
t.end(); | ||
function checkCondition (el, source) { | ||
t.equal(el.className, 'copyable', 'dragged element classname is copyable'); | ||
t.equal(source.className, 'contains', 'source container classname is contains'); | ||
return true; | ||
} | ||
drake.end(); | ||
}); | ||
function always () { return true; } | ||
function never () { return false; } |
@@ -27,3 +27,3 @@ 'use strict'; | ||
test('when already dragging, ends (cancels) previous drag', function (t) { | ||
test('when already dragging, .end() ends (cancels) previous drag', function (t) { | ||
var div = document.createElement('div'); | ||
@@ -30,0 +30,0 @@ var item1 = document.createElement('div'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
831656
2926
291