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 1.1.1 to 2.0.0

6

dist/draggable-helper.cjs.js
/*!
* draggable-helper v1.1.1
* draggable-helper v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

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

opt.getEl(dragHandlerEl, opt, store) get the el that will be moved. default is dragHandlerEl
afterGetEl(startEvent, opt, store)
afterGetEl(opt, store)
opt.minTranslate default 10, unit px

@@ -139,3 +139,3 @@ [Boolean] opt.triggerBySelf: false if trigger only by self, can not be triggered by children

store.initialPosition = Object.assign({}, position);
opt.afterGetEl && opt.afterGetEl(e, opt, store); // dom actions
opt.afterGetEl && opt.afterGetEl(opt, store); // dom actions

@@ -142,0 +142,0 @@ var size = hp.getElSize(el);

/*!
* draggable-helper v1.1.1
* draggable-helper v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

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

opt.getEl(dragHandlerEl, opt, store) get the el that will be moved. default is dragHandlerEl
afterGetEl(startEvent, opt, store)
afterGetEl(opt, store)
opt.minTranslate default 10, unit px

@@ -135,3 +135,3 @@ [Boolean] opt.triggerBySelf: false if trigger only by self, can not be triggered by children

store.initialPosition = Object.assign({}, position);
opt.afterGetEl && opt.afterGetEl(e, opt, store); // dom actions
opt.afterGetEl && opt.afterGetEl(opt, store); // dom actions

@@ -138,0 +138,0 @@ var size = getElSize(el);

/*!
* draggable-helper v1.1.1
* draggable-helper v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

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

opt.getEl(dragHandlerEl, opt, store) get the el that will be moved. default is dragHandlerEl
afterGetEl(startEvent, opt, store)
afterGetEl(opt, store)
opt.minTranslate default 10, unit px

@@ -393,3 +393,3 @@ [Boolean] opt.triggerBySelf: false if trigger only by self, can not be triggered by children

store.initialPosition = Object.assign({}, position);
opt.afterGetEl && opt.afterGetEl(e, opt, store); // dom actions
opt.afterGetEl && opt.afterGetEl(opt, store); // dom actions

@@ -396,0 +396,0 @@ var size = getElSize(el);

/*!
* draggable-helper v1.1.1
* draggable-helper v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["helper-js"]=e()}(this,function(){"use strict";function t(t){for(var e=function(t){var e=t.offsetParent;return(!e||e===document.body&&"static"===getComputedStyle(document.body).position)&&(e=document.body.parentElement),e}(t),n={x:t.offsetLeft,y:t.offsetTop},o=t;(o=o.parentElement)!==e&&o;)n.x-=o.scrollLeft,n.y-=o.scrollTop;return n}function e(t,e){t["original_".concat(e)]=t.getAttribute(e)}function n(t,e){var n="original_".concat(e);t.setAttribute(e,t[n])}function o(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)}function r(t,e,n){for(var o=arguments.length,r=new Array(o>3?o-3:0),a=3;a<o;a++)r[a-3]=arguments[a];t.addEventListener?t.addEventListener.apply(t,[e,n].concat(r)):t.attachEvent&&t.attachEvent.apply(t,["on".concat(e),n].concat(r))}function a(t,e,n){for(var o=arguments.length,r=new Array(o>3?o-3:0),a=3;a<o;a++)r[a-3]=arguments[a];t.removeEventListener?t.removeEventListener.apply(t,[e,n].concat(r)):t.detachEvent&&t.detachEvent.apply(t,["on".concat(e),n].concat(r))}function i(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var s={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},c={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,o){var a,c,u=l(o),f=u.args,p=u.mouseArgs,g=u.touchArgs,d=this._getStore(t),v=this,m=function(t){var o;if(v.isTouch(t))o={x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY};else if(o={x:t.pageX,y:t.pageY},"start"===e&&1!==t.which)return;return n.call(this,t,o)};d.push({handler:n,wrapper:m}),(a=r).call.apply(a,[null,t,s[e][0],m].concat(i(f).concat(i(p)))),(c=r).call.apply(c,[null,t,s[e][1],m].concat(i(f).concat(i(g))))},off:function(t,e,n,o){for(var r=l(o),c=r.args,u=r.mouseArgs,f=this._getStore(t),p=f.length-1;p>=0;p--){var g,d,v=f[p],m=v.handler,y=v.wrapper;if(n===m)(g=a).call.apply(g,[null,t,s[e][0],y].concat(i(c).concat(i(u)))),(d=a).call.apply(d,[null,t,s[e][1],y].concat(i(c).concat(i(u)))),f.splice(p,1)}}};function l(t){return t||(t={}),{args:t.args||[],mouseArgs:t.mouseArgs||[],touchArgs:t.touchArgs||[]}}var u=["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],f="undraggable";return function(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a=Object.assign({minTranslate:10,draggingClass:"dragging"},a);var i={movedCount:0},s=function(){c.off(r,"start",r._draggbleEventHandler),delete r._draggbleEventHandler};return r._draggbleEventHandler&&s(),r._draggbleEventHandler=l,c.on(r,"start",l),s;function l(t,e){a.triggerBySelf&&t.target!==r||u.includes(t.target.tagName)||o(t.target,f)||function(t,e,n){for(var o=n&&n.withSelf?t:t.parentElement;o;){var r=e(o);if("break"===r)return;if(r)return o;o=o.parentElement}}(t.target,function(t){return!!o(t,f)||(t===r?"break":void 0)})||(t.preventDefault(),i.mouse={x:e.x,y:e.y},i.startEvent=t,i.initialMouse=Object.assign({},i.mouse),c.on(document,"move",g,{touchArgs:[{passive:!1}]}),c.on(window,"end",d))}function p(n){if(!1===(a.drag&&a.drag(i.startEvent,n,a,i)))return!1;var s=function(){var e=a.getEl?a.getEl(r,a,i):r,n=e;return i.originalEl=e,a.clone&&(n=e.cloneNode(!0),e.parentElement.appendChild(n)),{position:t(e),el:n}}(),c=s.el,l=s.position;i.el=c,i.initialPosition=Object.assign({},l),a.afterGetEl&&a.afterGetEl(n,a,i);var u=function(t){var e=t.style.display;t.style.display="block";var n={width:t.offsetWidth,height:t.offsetHeight};return t.style.display=e,n}(c),f=Object.assign({width:"".concat(u.width,"px"),height:"".concat(u.height,"px"),zIndex:9999,opacity:.6,position:"absolute",left:l.x+"px",top:l.y+"px"},a.style||a.getStyle&&a.getStyle(a,i)||{});for(var p in e(c,"style"),f)c.style[p]=f[p];e(c,"class"),function(t,e){o(t,e)||(t.classList?t.classList.add(e):t.className+=" "+e)}(c,a.draggingClass)}function g(t,e){t.preventDefault(),i.mouse={x:e.x,y:e.y};var n=i.move={x:i.mouse.x-i.initialMouse.x,y:i.mouse.y-i.initialMouse.y};if(0===i.movedCount&&a.minTranslate){var o=Math.pow(i.move.x,2),r=Math.pow(i.move.y,2);if(Math.pow(o+r,.5)<a.minTranslate)return}var s=!0;if(0===i.movedCount&&!1===p(t)&&(s=!1),s&&a.moving&&!1===a.moving(t,a,i)&&(s=!1),s){if(!i||!i.el)return;Object.assign(i.el.style,{left:i.initialPosition.x+n.x+"px",top:i.initialPosition.y+n.y+"px"}),i.movedCount++}}function d(t){if(c.off(document,"move",g,{touchArgs:[{passive:!1}]}),c.off(window,"end",d),i.movedCount>0){i.movedCount=0;var e=i.el;a.clone?e.parentElement.removeChild(e):(n(e,"style"),n(e,"class")),a.drop&&a.drop(t,a,i)}i={movedCount:0}}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["helper-js"]=e()}(this,function(){"use strict";function t(t){for(var e=function(t){var e=t.offsetParent;return(!e||e===document.body&&"static"===getComputedStyle(document.body).position)&&(e=document.body.parentElement),e}(t),n={x:t.offsetLeft,y:t.offsetTop},o=t;(o=o.parentElement)!==e&&o;)n.x-=o.scrollLeft,n.y-=o.scrollTop;return n}function e(t,e){t["original_".concat(e)]=t.getAttribute(e)}function n(t,e){var n="original_".concat(e);t.setAttribute(e,t[n])}function o(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)}function r(t,e,n){for(var o=arguments.length,r=new Array(o>3?o-3:0),a=3;a<o;a++)r[a-3]=arguments[a];t.addEventListener?t.addEventListener.apply(t,[e,n].concat(r)):t.attachEvent&&t.attachEvent.apply(t,["on".concat(e),n].concat(r))}function a(t,e,n){for(var o=arguments.length,r=new Array(o>3?o-3:0),a=3;a<o;a++)r[a-3]=arguments[a];t.removeEventListener?t.removeEventListener.apply(t,[e,n].concat(r)):t.detachEvent&&t.detachEvent.apply(t,["on".concat(e),n].concat(r))}function i(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var s={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},c={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,o){var a,c,u=l(o),f=u.args,p=u.mouseArgs,g=u.touchArgs,d=this._getStore(t),v=this,m=function(t){var o;if(v.isTouch(t))o={x:t.changedTouches[0].pageX,y:t.changedTouches[0].pageY};else if(o={x:t.pageX,y:t.pageY},"start"===e&&1!==t.which)return;return n.call(this,t,o)};d.push({handler:n,wrapper:m}),(a=r).call.apply(a,[null,t,s[e][0],m].concat(i(f).concat(i(p)))),(c=r).call.apply(c,[null,t,s[e][1],m].concat(i(f).concat(i(g))))},off:function(t,e,n,o){for(var r=l(o),c=r.args,u=r.mouseArgs,f=this._getStore(t),p=f.length-1;p>=0;p--){var g,d,v=f[p],m=v.handler,y=v.wrapper;if(n===m)(g=a).call.apply(g,[null,t,s[e][0],y].concat(i(c).concat(i(u)))),(d=a).call.apply(d,[null,t,s[e][1],y].concat(i(c).concat(i(u)))),f.splice(p,1)}}};function l(t){return t||(t={}),{args:t.args||[],mouseArgs:t.mouseArgs||[],touchArgs:t.touchArgs||[]}}var u=["INPUT","TEXTAREA","SELECT","OPTGROUP","OPTION"],f="undraggable";return function(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a=Object.assign({minTranslate:10,draggingClass:"dragging"},a);var i={movedCount:0},s=function(){c.off(r,"start",r._draggbleEventHandler),delete r._draggbleEventHandler};return r._draggbleEventHandler&&s(),r._draggbleEventHandler=l,c.on(r,"start",l),s;function l(t,e){a.triggerBySelf&&t.target!==r||u.includes(t.target.tagName)||o(t.target,f)||function(t,e,n){for(var o=n&&n.withSelf?t:t.parentElement;o;){var r=e(o);if("break"===r)return;if(r)return o;o=o.parentElement}}(t.target,function(t){return!!o(t,f)||(t===r?"break":void 0)})||(t.preventDefault(),i.mouse={x:e.x,y:e.y},i.startEvent=t,i.initialMouse=Object.assign({},i.mouse),c.on(document,"move",g,{touchArgs:[{passive:!1}]}),c.on(window,"end",d))}function p(n){if(!1===(a.drag&&a.drag(i.startEvent,n,a,i)))return!1;var s=function(){var e=a.getEl?a.getEl(r,a,i):r,n=e;return i.originalEl=e,a.clone&&(n=e.cloneNode(!0),e.parentElement.appendChild(n)),{position:t(e),el:n}}(),c=s.el,l=s.position;i.el=c,i.initialPosition=Object.assign({},l),a.afterGetEl&&a.afterGetEl(a,i);var u=function(t){var e=t.style.display;t.style.display="block";var n={width:t.offsetWidth,height:t.offsetHeight};return t.style.display=e,n}(c),f=Object.assign({width:"".concat(u.width,"px"),height:"".concat(u.height,"px"),zIndex:9999,opacity:.6,position:"absolute",left:l.x+"px",top:l.y+"px"},a.style||a.getStyle&&a.getStyle(a,i)||{});for(var p in e(c,"style"),f)c.style[p]=f[p];e(c,"class"),function(t,e){o(t,e)||(t.classList?t.classList.add(e):t.className+=" "+e)}(c,a.draggingClass)}function g(t,e){t.preventDefault(),i.mouse={x:e.x,y:e.y};var n=i.move={x:i.mouse.x-i.initialMouse.x,y:i.mouse.y-i.initialMouse.y};if(0===i.movedCount&&a.minTranslate){var o=Math.pow(i.move.x,2),r=Math.pow(i.move.y,2);if(Math.pow(o+r,.5)<a.minTranslate)return}var s=!0;if(0===i.movedCount&&!1===p(t)&&(s=!1),s&&a.moving&&!1===a.moving(t,a,i)&&(s=!1),s){if(!i||!i.el)return;Object.assign(i.el.style,{left:i.initialPosition.x+n.x+"px",top:i.initialPosition.y+n.y+"px"}),i.movedCount++}}function d(t){if(c.off(document,"move",g,{touchArgs:[{passive:!1}]}),c.off(window,"end",d),i.movedCount>0){i.movedCount=0;var e=i.el;a.clone?e.parentElement.removeChild(e):(n(e,"style"),n(e,"class")),a.drop&&a.drop(t,a,i)}i={movedCount:0}}}});
//# sourceMappingURL=draggable-helper.min.js.map
{
"name": "draggable-helper",
"version": "1.1.1",
"version": "2.0.0",
"description": "",

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

@@ -35,3 +35,3 @@ # draggable-helper

// getEl(dragHandlerEl, opt, store), optional, get the el that will be moved. default is dragHandlerEl
// afterGetEl(startEvent, opt, store)
// afterGetEl(opt, store)
// [Boolean] triggerBySelf if trigger only by dragHandlerEl self, can not be triggered by children

@@ -38,0 +38,0 @@ // hook, when drag start

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