Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

draggable-helper

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draggable-helper - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

22

dist/draggable-helper.cjs.js
/*!
* draggable-helper v3.0.1
* draggable-helper v3.0.2
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

@@ -336,2 +336,3 @@ * Released under the MIT License.

[Boolean] opt.triggerBySelf: false if trigger only by self, can not be triggered by children
[Boolean] opt.restoreDOMManuallyOndrop the changed DOM will be restored automatically on drop. This disable it and pass restoreDOM function into store.

@@ -349,2 +350,3 @@ add other prop into opt, you can get opt in callback

endEvent
restoreDOM // function if opt.restoreDOMManuallyOndrop else null
}

@@ -546,9 +548,17 @@ e.g.

if (opt.clone) {
el.parentElement.removeChild(el);
} else {
restoreAttr(el, 'style');
restoreAttr(el, 'class');
var restoreDOM = function restoreDOM() {
if (opt.clone) {
el.parentElement.removeChild(el);
} else {
restoreAttr(el, 'style');
restoreAttr(el, 'class');
}
};
if (!opt.restoreDOMManuallyOndrop) {
restoreDOM();
restoreDOM = null;
}
store.restoreDOM = restoreDOM;
opt.drop && opt.drop(e, store, opt);

@@ -555,0 +565,0 @@ }

/*!
* draggable-helper v3.0.1
* draggable-helper v3.0.2
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

@@ -332,2 +332,3 @@ * Released under the MIT License.

[Boolean] opt.triggerBySelf: false if trigger only by self, can not be triggered by children
[Boolean] opt.restoreDOMManuallyOndrop the changed DOM will be restored automatically on drop. This disable it and pass restoreDOM function into store.

@@ -345,2 +346,3 @@ add other prop into opt, you can get opt in callback

endEvent
restoreDOM // function if opt.restoreDOMManuallyOndrop else null
}

@@ -542,9 +544,17 @@ e.g.

if (opt.clone) {
el.parentElement.removeChild(el);
} else {
restoreAttr(el, 'style');
restoreAttr(el, 'class');
var restoreDOM = function restoreDOM() {
if (opt.clone) {
el.parentElement.removeChild(el);
} else {
restoreAttr(el, 'style');
restoreAttr(el, 'class');
}
};
if (!opt.restoreDOMManuallyOndrop) {
restoreDOM();
restoreDOM = null;
}
store.restoreDOM = restoreDOM;
opt.drop && opt.drop(e, store, opt);

@@ -551,0 +561,0 @@ }

/*!
* draggable-helper v3.0.1
* draggable-helper v3.0.2
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

@@ -338,2 +338,3 @@ * Released under the MIT License.

[Boolean] opt.triggerBySelf: false if trigger only by self, can not be triggered by children
[Boolean] opt.restoreDOMManuallyOndrop the changed DOM will be restored automatically on drop. This disable it and pass restoreDOM function into store.

@@ -351,2 +352,3 @@ add other prop into opt, you can get opt in callback

endEvent
restoreDOM // function if opt.restoreDOMManuallyOndrop else null
}

@@ -548,9 +550,17 @@ e.g.

if (opt.clone) {
el.parentElement.removeChild(el);
} else {
restoreAttr(el, 'style');
restoreAttr(el, 'class');
var restoreDOM = function restoreDOM() {
if (opt.clone) {
el.parentElement.removeChild(el);
} else {
restoreAttr(el, 'style');
restoreAttr(el, 'class');
}
};
if (!opt.restoreDOMManuallyOndrop) {
restoreDOM();
restoreDOM = null;
}
store.restoreDOM = restoreDOM;
opt.drop && opt.drop(e, store, opt);

@@ -557,0 +567,0 @@ }

/*!
* draggable-helper v3.0.1
* draggable-helper v3.0.2
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

@@ -17,3 +17,3 @@ * Released under the MIT License.

*/
function u(t,e,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];t.addEventListener?t.addEventListener.apply(t,[e,n].concat(o)):t.attachEvent&&t.attachEvent.apply(t,["on".concat(e),n].concat(o))}function s(t,e,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];t.removeEventListener?t.removeEventListener.apply(t,[e,n].concat(o)):t.detachEvent&&t.detachEvent.apply(t,["on".concat(e),n].concat(o))}var f={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},p={isTouch:function(t){return t.type&&t.type.startsWith("touch")},_getStore:function(t){return t._wrapperStore||(t._wrapperStore=[]),t._wrapperStore},on:function(t,e,n,r){var a=g(r),i=a.args,c=a.mouseArgs,l=a.touchArgs,s=this._getStore(t),p=this,d=function(t){var r;if(p.isTouch(t))r={x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY};else if(r={x:t.pageX,y:t.pageY},"start"===e&&1!==t.which)return;return n.call(this,t,r)};s.push({handler:n,wrapper:d}),u.call.apply(u,[null,t,f[e][0],d].concat([].concat(o(i),o(c)))),u.call.apply(u,[null,t,f[e][1],d].concat([].concat(o(i),o(l))))},off:function(t,e,n,r){for(var a=g(r),i=a.args,c=a.mouseArgs,l=this._getStore(t),u=l.length-1;u>=0;u--){var p=l[u],d=p.handler,v=p.wrapper;n===d&&(s.call.apply(s,[null,t,f[e][0],v].concat([].concat(o(i),o(c)))),s.call.apply(s,[null,t,f[e][1],v].concat([].concat(o(i),o(c)))),l.splice(u,1))}}};function g(t){return t||(t={}),{args:t.args||[],mouseArgs:t.mouseArgs||[],touchArgs:t.touchArgs||[]}}var d=["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],v="undraggable";t.default=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=r({minTranslate:10,draggingClass:"dragging"},e);var n={movedCount:0},o=function(){p.off(t,"start",t._draggbleEventHandler),delete t._draggbleEventHandler};return t._draggbleEventHandler&&o(),t._draggbleEventHandler=u,p.on(t,"start",u),o;function u(o,a){e.triggerBySelf&&o.target!==t||(d.includes(o.target.tagName)||l(o.target,v)||function(t,e,n){for(var r=n&&n.withSelf?t:t.parentElement;r;){var o=e(r);if("break"===o)return;if(o)return r;r=r.parentElement}}(o.target,(function(e){return!!l(e,v)||(e===t?"break":void 0)}))||(o.preventDefault(),n.mouse={x:a.x,y:a.y},n.startEvent=o,n.initialMouse=r({},n.mouse),p.on(document,"move",f,{touchArgs:[{passive:!1}]}),p.on(window,"end",g)))}function s(o){var c=e.beforeDrag&&e.beforeDrag(n.startEvent,o,n,e);if(!1===c)return!1;var u=function(){var r=e.getEl?e.getEl(t,n,e):t,o=r;n.originalEl=r,e.clone&&(o=r.cloneNode(!0),r.parentElement.appendChild(o));return{position:a(r),el:o}}(),s=u.el,f=u.position;if(n.el=s,n.initialPosition=r({},f),!1===(c=e.drag&&e.drag(n.startEvent,o,n,e)))return!1;var p=function(t){var e=t.getBoundingClientRect(),n=e.top-document.documentElement.clientTop,r=e.bottom,o=e.left-document.documentElement.clientLeft,a=e.right;return{top:n,right:a,bottom:r,left:o,width:e.width||a-o,height:e.height||r-n,x:o,y:n}}(s),g=r({width:"".concat(Math.ceil(p.width),"px"),height:"".concat(Math.ceil(p.height),"px"),zIndex:9999,opacity:.8,position:"absolute",left:f.x+"px",top:f.y+"px"},e.style||e.getStyle&&e.getStyle(n,e)||{});for(var d in i(s,"style"),g)s.style[d]=g[d];i(s,"class"),function(t,e){l(t,e)||(t.classList?t.classList.add(e):t.className+=" "+e)}(s,e.draggingClass)}function f(t,r){t.preventDefault(),n.mouse={x:r.x,y:r.y};var o=n.move={x:n.mouse.x-n.initialMouse.x,y:n.mouse.y-n.initialMouse.y};if(0===n.movedCount&&e.minTranslate){var a=Math.pow(n.move.x,2),i=Math.pow(n.move.y,2);if(Math.pow(a+i,.5)<e.minTranslate)return}var c=!0;if(0===n.movedCount&&!1===s(t)&&(c=!1),c&&e.moving&&!1===e.moving(t,n,e)&&(c=!1),c){if(!n||!n.el)return;Object.assign(n.el.style,{left:n.initialPosition.x+o.x+"px",top:n.initialPosition.y+o.y+"px"}),n.movedCount++}}function g(t){if(p.off(document,"move",f,{touchArgs:[{passive:!1}]}),p.off(window,"end",g),n.movedCount>0){n.movedCount=0,n.endEvent=t;var r=n.el;e.clone?r.parentElement.removeChild(r):(c(r,"style"),c(r,"class")),e.drop&&e.drop(t,n,e)}n={movedCount:0}}},Object.defineProperty(t,"__esModule",{value:!0})}));
function u(t,e,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];t.addEventListener?t.addEventListener.apply(t,[e,n].concat(o)):t.attachEvent&&t.attachEvent.apply(t,["on".concat(e),n].concat(o))}function s(t,e,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];t.removeEventListener?t.removeEventListener.apply(t,[e,n].concat(o)):t.detachEvent&&t.detachEvent.apply(t,["on".concat(e),n].concat(o))}var f={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},p={isTouch:function(t){return t.type&&t.type.startsWith("touch")},_getStore:function(t){return t._wrapperStore||(t._wrapperStore=[]),t._wrapperStore},on:function(t,e,n,r){var a=g(r),i=a.args,c=a.mouseArgs,l=a.touchArgs,s=this._getStore(t),p=this,d=function(t){var r;if(p.isTouch(t))r={x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY};else if(r={x:t.pageX,y:t.pageY},"start"===e&&1!==t.which)return;return n.call(this,t,r)};s.push({handler:n,wrapper:d}),u.call.apply(u,[null,t,f[e][0],d].concat([].concat(o(i),o(c)))),u.call.apply(u,[null,t,f[e][1],d].concat([].concat(o(i),o(l))))},off:function(t,e,n,r){for(var a=g(r),i=a.args,c=a.mouseArgs,l=this._getStore(t),u=l.length-1;u>=0;u--){var p=l[u],d=p.handler,v=p.wrapper;n===d&&(s.call.apply(s,[null,t,f[e][0],v].concat([].concat(o(i),o(c)))),s.call.apply(s,[null,t,f[e][1],v].concat([].concat(o(i),o(c)))),l.splice(u,1))}}};function g(t){return t||(t={}),{args:t.args||[],mouseArgs:t.mouseArgs||[],touchArgs:t.touchArgs||[]}}var d=["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],v="undraggable";t.default=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=r({minTranslate:10,draggingClass:"dragging"},e);var n={movedCount:0},o=function(){p.off(t,"start",t._draggbleEventHandler),delete t._draggbleEventHandler};return t._draggbleEventHandler&&o(),t._draggbleEventHandler=u,p.on(t,"start",u),o;function u(o,a){e.triggerBySelf&&o.target!==t||(d.includes(o.target.tagName)||l(o.target,v)||function(t,e,n){for(var r=n&&n.withSelf?t:t.parentElement;r;){var o=e(r);if("break"===o)return;if(o)return r;r=r.parentElement}}(o.target,(function(e){return!!l(e,v)||(e===t?"break":void 0)}))||(o.preventDefault(),n.mouse={x:a.x,y:a.y},n.startEvent=o,n.initialMouse=r({},n.mouse),p.on(document,"move",f,{touchArgs:[{passive:!1}]}),p.on(window,"end",g)))}function s(o){var c=e.beforeDrag&&e.beforeDrag(n.startEvent,o,n,e);if(!1===c)return!1;var u=function(){var r=e.getEl?e.getEl(t,n,e):t,o=r;n.originalEl=r,e.clone&&(o=r.cloneNode(!0),r.parentElement.appendChild(o));return{position:a(r),el:o}}(),s=u.el,f=u.position;if(n.el=s,n.initialPosition=r({},f),!1===(c=e.drag&&e.drag(n.startEvent,o,n,e)))return!1;var p=function(t){var e=t.getBoundingClientRect(),n=e.top-document.documentElement.clientTop,r=e.bottom,o=e.left-document.documentElement.clientLeft,a=e.right;return{top:n,right:a,bottom:r,left:o,width:e.width||a-o,height:e.height||r-n,x:o,y:n}}(s),g=r({width:"".concat(Math.ceil(p.width),"px"),height:"".concat(Math.ceil(p.height),"px"),zIndex:9999,opacity:.8,position:"absolute",left:f.x+"px",top:f.y+"px"},e.style||e.getStyle&&e.getStyle(n,e)||{});for(var d in i(s,"style"),g)s.style[d]=g[d];i(s,"class"),function(t,e){l(t,e)||(t.classList?t.classList.add(e):t.className+=" "+e)}(s,e.draggingClass)}function f(t,r){t.preventDefault(),n.mouse={x:r.x,y:r.y};var o=n.move={x:n.mouse.x-n.initialMouse.x,y:n.mouse.y-n.initialMouse.y};if(0===n.movedCount&&e.minTranslate){var a=Math.pow(n.move.x,2),i=Math.pow(n.move.y,2);if(Math.pow(a+i,.5)<e.minTranslate)return}var c=!0;if(0===n.movedCount&&!1===s(t)&&(c=!1),c&&e.moving&&!1===e.moving(t,n,e)&&(c=!1),c){if(!n||!n.el)return;Object.assign(n.el.style,{left:n.initialPosition.x+o.x+"px",top:n.initialPosition.y+o.y+"px"}),n.movedCount++}}function g(t){if(p.off(document,"move",f,{touchArgs:[{passive:!1}]}),p.off(window,"end",g),n.movedCount>0){n.movedCount=0,n.endEvent=t;var r=n.el,o=function(){e.clone?r.parentElement.removeChild(r):(c(r,"style"),c(r,"class"))};e.restoreDOMManuallyOndrop||(o(),o=null),n.restoreDOM=o,e.drop&&e.drop(t,n,e)}n={movedCount:0}}},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=draggable-helper.min.js.map
{
"name": "draggable-helper",
"version": "3.0.1",
"version": "3.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/draggable-helper.cjs.js",

@@ -38,2 +38,3 @@ # draggable-helper

// hook, before drag start
// [Boolean] opt.restoreDOMManuallyOndrop the changed DOM will be restored automatically on drop. This disable it and pass restoreDOM function into store.
beforeDrag(startEvent, moveEvent, store, opt){

@@ -67,3 +68,4 @@ // when trigger drag, the position must be moved, so there are two event. startEvent also can be accessed by store.startEvent

startEvent // mousedown or touchstart event
endEvent
endEvent,
restoreDOM() // function if opt.restoreDOMManuallyOndrop else null
}

@@ -70,0 +72,0 @@ ```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc