@dflex/draggable
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
var t=function t(e){var n=e.element,r=function(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}(e,["element"]);!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=n,Object.assign(this,r)},e=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.registry={}}var e;return(e=[{key:"register",value:function(t,e){var n=t.id;this.registry[n]="function"==typeof e?new e(t):t}},{key:"getElmById",value:function(t){return this.registry[t]}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,n){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var a,f=(a||(a=new(function(n){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}(p,e);var a,f,l,s=(f=p,l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=u(f);if(l){var n=u(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return c(this,t)});function p(){return r(this,p),s.apply(this,arguments)}return(a=[{key:"register",value:function(e){o(u(p.prototype),"register",this).call(this,Object.assign(e,{translateY:0,translateX:0}),t)}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(p.prototype,a),p}())),a),l=[{prop:"pointerEvents",value:"none"},{prop:"zIndex",value:"1"},{prop:"transition",value:"opacity 0.2s cubic-bezier(0.2, 0, 0, 1) 0s"}],s=function(){function t(e,n){var r=n.x,o=n.y;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.draggedElm=e;var i=this.draggedElm,c=i.translateX,u=i.translateY,a=i.element.style;this.draggedStyle=a,this.offsetX=-r+c,this.offsetY=-o+u,this.setDragged(!0)}var e;return(e=[{key:"setDragged",value:function(t){var e=this;t?l.forEach(function(t){var n=t.prop,r=t.value;e.draggedStyle[n]=r}):this.draggedStyle.pointerEvents=null}},{key:"end",value:function(){this.setDragged(!1)}},{key:"dragAt",value:function(t,e){this.draggedElm.translateX=t+this.offsetX,this.draggedElm.translateY=e+this.offsetY,this.draggedStyle.transform="translate(".concat(this.draggedElm.translateX,"px,").concat(this.draggedElm.translateY,"px)")}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t,e){return!e||"object"!==p(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var g=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&y(t,e)}(o,s);var e,n,r=(e=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,r=h(e);if(n){var o=h(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return b(this,t)});function o(t,e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o);var n=f.getElmById(t);return r.call(this,n,e)}return o}();exports.Draggable=g,exports.store=f; | ||
var t=function t(e){var n=e.element,r=function(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}(e,["element"]);!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=n,Object.assign(this,r)},e=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.registry={}}var e;return(e=[{key:"register",value:function(t,e){var n=t.id;this.registry[n]="function"==typeof e?new e(t):t}},{key:"getElmById",value:function(t){return this.registry[t]}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,n){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var u=new(function(n){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}(p,e);var u,f,l,s=(f=p,l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=c(f);if(l){var n=c(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return a(this,t)});function p(){return r(this,p),s.apply(this,arguments)}return(u=[{key:"register",value:function(e){o(c(p.prototype),"register",this).call(this,Object.assign(e,{translateY:0,translateX:0}),t)}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(p.prototype,u),p}()),f=[{prop:"pointerEvents",value:"none"},{prop:"zIndex",value:"1"},{prop:"transition",value:"opacity 0.2s cubic-bezier(0.2, 0, 0, 1) 0s"}],l=function(){function t(e,n){var r=n.x,o=n.y;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.draggedElm=e;var i=this.draggedElm,a=i.translateX,c=i.translateY,u=i.element.style;this.draggedStyle=u,this.outerOffsetX=-r+a,this.outerOffsetY=-o+c,this.tempTranslate={x:0,y:0},this.setDragged(!0)}var e;return(e=[{key:"setDragged",value:function(t){var e=this;t?f.forEach(function(t){var n=t.prop,r=t.value;e.draggedStyle[n]=r}):f.forEach(function(t){var n=t.prop;e.draggedStyle[n]=null})}},{key:"translate",value:function(t,e){this.tempTranslate.x=t+this.outerOffsetX,this.tempTranslate.y=e+this.outerOffsetY,this.draggedStyle.transform="translate(".concat(this.tempTranslate.x,"px,").concat(this.tempTranslate.y,"px)")}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}();function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(t,e){return!e||"object"!==s(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}(i,l);var e,n,r,o=(n=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=h(n);if(r){var o=h(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return y(this,t)});function i(t,e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i);var n=u.getElmById(t);return o.call(this,n,e)}return(e=[{key:"dragAt",value:function(t,e){this.translate(t,e),this.draggedElm.translateX=this.tempTranslate.x,this.draggedElm.translateY=this.tempTranslate.y}},{key:"endDragging",value:function(){this.setDragged(!1)}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,e),i}();exports.Draggable=b,exports.store=u; | ||
//# sourceMappingURL=dflexDraggable.min.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).dflexDraggable={})}(this,function(t){var e=function t(e){var n=e.element,r=function(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}(e,["element"]);!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=n,Object.assign(this,r)};function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,n){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=f(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var u,a=(u||(u=new(function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}(s,t);var n,u,a,l=(u=s,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=f(u);if(a){var n=f(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return c(this,t)});function s(){return r(this,s),l.apply(this,arguments)}return(n=[{key:"register",value:function(t){o(f(s.prototype),"register",this).call(this,Object.assign(t,{translateY:0,translateX:0}),e)}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(s.prototype,n),s}(function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.registry={}}var e;return(e=[{key:"register",value:function(t,e){var n=t.id;this.registry[n]="function"==typeof e?new e(t):t}},{key:"getElmById",value:function(t){return this.registry[t]}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}()))),u),l=[{prop:"pointerEvents",value:"none"},{prop:"zIndex",value:"1"},{prop:"transition",value:"opacity 0.2s cubic-bezier(0.2, 0, 0, 1) 0s"}];function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(t,e){return!e||"object"!==s(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function b(t){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var h=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}(o,t);var e,n,r=(e=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,r=b(e);if(n){var o=b(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return y(this,t)});function o(t,e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o);var n=a.getElmById(t);return r.call(this,n,e)}return o}(function(){function t(e,n){var r=n.x,o=n.y;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.draggedElm=e;var i=this.draggedElm,c=i.translateX,f=i.translateY,u=i.element.style;this.draggedStyle=u,this.offsetX=-r+c,this.offsetY=-o+f,this.setDragged(!0)}var e;return(e=[{key:"setDragged",value:function(t){var e=this;t?l.forEach(function(t){var n=t.prop,r=t.value;e.draggedStyle[n]=r}):this.draggedStyle.pointerEvents=null}},{key:"end",value:function(){this.setDragged(!1)}},{key:"dragAt",value:function(t,e){this.draggedElm.translateX=t+this.offsetX,this.draggedElm.translateY=e+this.offsetY,this.draggedStyle.transform="translate(".concat(this.draggedElm.translateX,"px,").concat(this.draggedElm.translateY,"px)")}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}());t.Draggable=h,t.store=a}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).dflexDraggable={})}(this,function(t){var e=function t(e){var n=e.element,r=function(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}(e,["element"]);!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.element=n,Object.assign(this,r)};function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,n){return(o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var c=new(function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}(s,t);var n,c,f,l=(c=s,f=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=u(c);if(f){var n=u(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return a(this,t)});function s(){return r(this,s),l.apply(this,arguments)}return(n=[{key:"register",value:function(t){o(u(s.prototype),"register",this).call(this,Object.assign(t,{translateY:0,translateX:0}),e)}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(s.prototype,n),s}(function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.registry={}}var e;return(e=[{key:"register",value:function(t,e){var n=t.id;this.registry[n]="function"==typeof e?new e(t):t}},{key:"getElmById",value:function(t){return this.registry[t]}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}())),f=[{prop:"pointerEvents",value:"none"},{prop:"zIndex",value:"1"},{prop:"transition",value:"opacity 0.2s cubic-bezier(0.2, 0, 0, 1) 0s"}];function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t,e){return!e||"object"!==l(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function y(t){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(i,t);var e,n,r,o=(n=i,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}(),function(){var t,e=y(n);if(r){var o=y(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return p(this,t)});function i(t,e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i);var n=c.getElmById(t);return o.call(this,n,e)}return(e=[{key:"dragAt",value:function(t,e){this.translate(t,e),this.draggedElm.translateX=this.tempTranslate.x,this.draggedElm.translateY=this.tempTranslate.y}},{key:"endDragging",value:function(){this.setDragged(!1)}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(i.prototype,e),i}(function(){function t(e,n){var r=n.x,o=n.y;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.draggedElm=e;var i=this.draggedElm,a=i.translateX,u=i.translateY,c=i.element.style;this.draggedStyle=c,this.outerOffsetX=-r+a,this.outerOffsetY=-o+u,this.tempTranslate={x:0,y:0},this.setDragged(!0)}var e;return(e=[{key:"setDragged",value:function(t){var e=this;t?f.forEach(function(t){var n=t.prop,r=t.value;e.draggedStyle[n]=r}):f.forEach(function(t){var n=t.prop;e.draggedStyle[n]=null})}},{key:"translate",value:function(t,e){this.tempTranslate.x=t+this.outerOffsetX,this.tempTranslate.y=e+this.outerOffsetY,this.draggedStyle.transform="translate(".concat(this.tempTranslate.x,"px,").concat(this.tempTranslate.y,"px)")}}])&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}());t.Draggable=b,t.store=c}); | ||
//# sourceMappingURL=dflexDraggable.min.umd.js.map |
{ | ||
"name": "@dflex/draggable", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"main": "dist/dflexDraggable.min.cjs.js", | ||
@@ -33,3 +33,3 @@ "umd:main": "dist/dflexDraggable.min.umd", | ||
}, | ||
"gitHead": "bdc3d06b58185c67703284588c34b91a76eb0955" | ||
"gitHead": "bcaccc56dfba58ee492c134ccaad114445ba9055" | ||
} |
@@ -49,3 +49,3 @@ # @dflex/draggable | ||
```ts | ||
draggable.end(); | ||
draggable.endDragging(); | ||
``` | ||
@@ -62,3 +62,5 @@ | ||
TODO | ||
```sh | ||
yarn test draggable | ||
``` | ||
@@ -65,0 +67,0 @@ ## License |
@@ -61,4 +61,4 @@ import { DRAGGED_ELM } from "../constants.json"; | ||
* calculate offset that make translate X,Y start from zero: | ||
* goToX = x + this.offsetX. | ||
* goToY = y + this.offsetY. | ||
* goToX = x + this.outerOffsetX. | ||
* goToY = y + this.outerOffsetY. | ||
* | ||
@@ -69,5 +69,10 @@ * goToX and goToY both should be zero with first click. Starts with simple | ||
*/ | ||
this.offsetX = -initX + translateX; | ||
this.offsetY = -initY + translateY; | ||
this.outerOffsetX = -initX + translateX; | ||
this.outerOffsetY = -initY + translateY; | ||
this.tempTranslate = { | ||
x: 0, | ||
y: 0, | ||
}; | ||
this.setDragged(true); | ||
@@ -95,9 +100,7 @@ } | ||
*/ | ||
this.draggedStyle.pointerEvents = null; | ||
draggedStyleProps.forEach(({ prop }) => { | ||
this.draggedStyle[prop] = null; | ||
}); | ||
} | ||
end() { | ||
this.setDragged(false); | ||
} | ||
/** | ||
@@ -112,3 +115,3 @@ * Executes dragging by applying transform. | ||
*/ | ||
dragAt(x, y) { | ||
translate(x, y) { | ||
/** | ||
@@ -121,6 +124,6 @@ * Calculates translate coordinates. | ||
*/ | ||
this[DRAGGED_ELM].translateX = x + this.offsetX; | ||
this[DRAGGED_ELM].translateY = y + this.offsetY; | ||
this.tempTranslate.x = x + this.outerOffsetX; | ||
this.tempTranslate.y = y + this.outerOffsetY; | ||
this.draggedStyle.transform = `translate(${this[DRAGGED_ELM].translateX}px,${this[DRAGGED_ELM].translateY}px)`; | ||
this.draggedStyle.transform = `translate(${this.tempTranslate.x}px,${this.tempTranslate.y}px)`; | ||
} | ||
@@ -127,0 +130,0 @@ } |
import store from "./DraggableStoreImp"; | ||
import AbstractDraggable from "./AbstractDraggable"; | ||
import { DRAGGED_ELM } from "../constants.json"; | ||
@@ -25,4 +26,15 @@ /** | ||
} | ||
dragAt(x, y) { | ||
this.translate(x, y); | ||
this[DRAGGED_ELM].translateX = this.tempTranslate.x; | ||
this[DRAGGED_ELM].translateY = this.tempTranslate.y; | ||
} | ||
endDragging() { | ||
this.setDragged(false); | ||
} | ||
} | ||
export default Draggable; |
@@ -9,3 +9,2 @@ import AbstractCoreInstance from "@dflex/core-instance/src/AbstractCoreInstance"; | ||
* @param {Object} elmInstance | ||
* @param {string} elmInstance.id | ||
* @param {node} elmInstance.element | ||
@@ -25,11 +24,7 @@ * @memberof DraggableStoreImp | ||
let store; | ||
// eslint-disable-next-line func-names | ||
export default (function () { | ||
if (!store) { | ||
store = new DraggableStoreImp(); | ||
} | ||
const store = new DraggableStoreImp(); | ||
return store; | ||
})(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
71443
225
68
0