You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
11 KiB
JavaScript

11 months ago
/*! mobile-drag-drop 3.0.0-rc.0 | Copyright (c) 2022 Tim Ruffles | MIT License */
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.MobileDragDrop=t.MobileDragDrop||{})}(this,function(t){"use strict";var c="dnd-poly-",s=["none","copy","copyLink","copyMove","link","linkMove","move","all"],f=["none","copy","move","link"];function i(){var t=!1;try{var i=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",null,i)}catch(t){}return t}var e=i();function l(t){return t&&t.tagName}function h(t,i,s){void 0===s&&(s=!0),document.addEventListener(t,i,!!e&&{passive:s})}function n(t,i){document.removeEventListener(t,i)}function u(t,i,s,n){void 0===n&&(n=!1);var h=e?{passive:!0,capture:n}:n;return t.addEventListener(i,s,h),{off:function(){t.removeEventListener(i,s,h)}}}function o(t){return 0===t.length?0:t.reduce(function(t,i){return i+t},0)/t.length}function r(t,i){for(var s=0;s<t.changedTouches.length;s++)if(t.changedTouches[s].identifier===i)return!0;return!1}function a(t,i,s){for(var n=[],h=[],e=0;e<i.touches.length;e++){var r=i.touches[e];n.push(r[t+"X"]),h.push(r[t+"Y"])}s.x=o(n),s.y=o(h)}var d=["","-webkit-"];function v(t,i,s,n,h){var e=i.x,i=i.y;n&&(e+=n.x,i+=n.y),(h=void 0===h||h)&&(e-=parseInt(t.offsetWidth,10)/2,i-=parseInt(t.offsetHeight,10)/2);for(var r="translate3d("+e+"px,"+i+"px, 0)",o=0;o<d.length;o++){var u=d[o]+"transform";t.style[u]=r+" "+s[o]}}var p=(Object.defineProperty(g.prototype,"dropEffect",{get:function(){return this.t},set:function(t){0!==this.i.mode&&-1<s.indexOf(t)&&(this.t=t)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"types",{get:function(){if(0!==this.i.mode)return Object.freeze(this.i.types)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"effectAllowed",{get:function(){return this.i.effectAllowed},set:function(t){2===this.i.mode&&-1<s.indexOf(t)&&(this.i.effectAllowed=t)},enumerable:!1,configurable:!0}),g.prototype.setData=function(t,i){if(2===this.i.mode){if(-1<t.indexOf(" "))throw new Error("illegal arg: type contains space");this.i.data[t]=i,-1===this.i.types.indexOf(t)&&this.i.types.push(t)}},g.prototype.getData=function(t){if(1===this.i.mode||2===this.i.mode)return this.i.data[t]||""},g.prototype.clearData=function(t){2===this.i.mode&&(t&&this.i.data[t]?(delete this.i.data[t],-1<(t=this.i.types.indexOf(t))&&this.i.types.splice(t,1)):(this.i.data={},this.i.types=[]))},g.prototype.setDragImage=function(t,i,s){2===this.i.mode&&this.h(t,i,s)},g);function g(t,i){this.i=t,this.h=i,this.t=f[0]}function m(t,i){return t?t===s[0]?f[0]:0===t.indexOf(s[1])||t===s[7]?f[1]:0===t.indexOf(s[4])?f[3]:t===s[6]?f[2]:f[1]:3===i.nodeType&&"A"===i.tagName?f[3]:f[1]}function y(u,t,a,i,s,n,c){void 0===c&&(c=null);s=function(t,i,s,n,h,e,r){void 0===c&&(r=null);var o=a.changedTouches[0],n=new Event(u,{bubbles:!0,cancelable:n});n.dataTransfer=e,n.relatedTarget=r,n.screenX=o.screenX,n.screenY=o.screenY,n.clientX=o.clientX,n.clientY=o.clientY,n.pageX=o.pageX,n.pageY=o.pageY;t=t.getBoundingClientRect();return n.offsetX=n.clientX-t.left,n.offsetY=n.clientY-t.top,n}(t,0,0,n=void 0===n||n,document.defaultView,s,c),s=!t.dispatchEvent(s);return i.mode=0,s}function b(t,i){if(!t||t===s[7])return i;if(i===f[1]){if(0===t.indexOf(f[1]))return f[1]}else if(i===f[3]){if(0===t.indexOf(f[3])||-1<t.indexOf("Link"))return f[3]}else if(i===f[2]&&(0===t.indexOf(f[2])||-1<t.indexOf("Move")))return f[2];return f[0]}var w=(x.prototype.o=function(){var n=this;this.u=1,this.l=f[0],this.v={data:{},effectAllowed:void 0,mode:3,types:[]},this.p={x:null,y:null},this.g={x:null,y:null};var h=this.m;if(this.I=new p(this.v,function(t,i,s){h=t,"number"!=typeof i&&"number"!=typeof s||(n.j={x:i||0,y:s||0})}),this.v.mode=2,this.I.dropEffect=f[0],y("dragstart",this.m,this.k,this.v,this.I))return this.u=3,this.C(),!1;a("page",this.k,this.g);var i,t,s=this.S.dragImageSetup(h);return this.A=(i=s,d.map(function(t){t=i.style[t+"transform"];return t&&"none"!==t?t.replace(/translate\(\D*\d+[^,]*,\D*\d+[^,]*\)\s*/g,""):""})),s.style.position="absolute",s.style.left="0px",s.style.
//# sourceMappingURL=index.min.js.map