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.0.17 to 1.0.18

22

dist/draggable-helper.cjs.js
/*!
* draggable-helper v1.0.17
* draggable-helper v1.0.18
* (c) 2018-present phphe <phphe@outlook.com> (https://github.com/phphe)

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

var helperJs = require('helper-js');
var hp = require('helper-js');
var DragEventService = _interopDefault(require('drag-event-service'));

@@ -61,3 +61,3 @@

DragEventService.off(dragHandlerEl, 'end', dragHandlerEl._draggbleEventHandler);
helperJs.offDOM(dragHandlerEl, 'selectstart', preventSelect);
hp.offDOM(dragHandlerEl, 'selectstart', preventSelect);
delete dragHandlerEl._draggbleEventHandler;

@@ -72,3 +72,3 @@ };

DragEventService.on(dragHandlerEl, 'start', dragHandlerEl._draggbleEventHandler);
helperJs.onDOM(dragHandlerEl, 'selectstart', preventSelect);
hp.onDOM(dragHandlerEl, 'selectstart', preventSelect);
return destroy;

@@ -104,3 +104,3 @@

var size = helperJs.getElSize(el);
var size = hp.getElSize(el);
var style = Object.assign({

@@ -115,3 +115,3 @@ width: "".concat(size.width, "px"),

}, opt.style || opt.getStyle && opt.getStyle(opt) || {});
helperJs.backupAttr(el, 'style');
hp.backupAttr(el, 'style');

@@ -123,4 +123,4 @@ for (var key in style) {

helperJs.backupAttr(el, 'class');
helperJs.addClass(el, opt.draggingClass);
hp.backupAttr(el, 'class');
hp.addClass(el, opt.draggingClass);
}

@@ -191,4 +191,4 @@

} else {
helperJs.restoreAttr(el, 'style');
helperJs.restoreAttr(el, 'class');
hp.restoreAttr(el, 'style');
hp.restoreAttr(el, 'class');
}

@@ -213,3 +213,3 @@

return {
position: helperJs.offsetToPosition(el, helperJs.getOffset(el0)),
position: hp.getPosition(el),
el: el

@@ -216,0 +216,0 @@ };

/*!
* draggable-helper v1.0.17
* draggable-helper v1.0.18
* (c) 2018-present phphe <phphe@outlook.com> (https://github.com/phphe)
* Released under the MIT License.
*/
import { onDOM, offDOM, getElSize, backupAttr, restoreAttr, getOffset, offsetToPosition, addClass } from 'helper-js';
import { offDOM, onDOM, getElSize, backupAttr, addClass, restoreAttr, getPosition } from 'helper-js';
import DragEventService from 'drag-event-service';

@@ -202,3 +202,3 @@

return {
position: offsetToPosition(el, getOffset(el0)),
position: getPosition(el),
el: el

@@ -205,0 +205,0 @@ };

/*!
* draggable-helper v1.0.17
* draggable-helper v1.0.18
* (c) 2018-present phphe <phphe@outlook.com> (https://github.com/phphe)

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

/*!
* helper-js v1.1.7
* helper-js v1.3.0
* (c) 2018-present phphe <phphe@outlook.com> (https://github.com/phphe)

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

function getScroll() {
if (typeof pageYOffset != 'undefined') {
//most browsers except IE before #9
return {
top: pageYOffset,
left: pageXOffset
};
} else {
var B = document.body; //IE 'quirks'
var D = document.documentElement; //IE with doctype
D = D.clientHeight ? D : B;
return {
top: D.scrollTop,
left: D.scrollLeft
};
}
} // refer: https://gist.github.com/aderaaij/89547e34617b95ac29d1
function getOffset(el) {
var rect = el.getBoundingClientRect();
var scroll = getScroll();
return {
x: rect.left + scroll.left,
y: rect.top + scroll.top
};
}
function offsetToPosition(el, of) {
function getOffsetParent(el) {
var offsetParent = el.offsetParent;

@@ -175,2 +147,9 @@

return offsetParent;
} // get el current position. like jQuery.position
// the position is relative to offsetParent viewport left top. it is for set absolute position, absolute position is relative to offsetParent viewport left top.
// 相对于offsetParent可视区域左上角(el.offsetLeft或top包含父元素的滚动距离, 所以要减去). position一般用于设置绝对定位的情况, 而绝对定位就是以可视区域左上角为原点.
function getPosition(el) {
var offsetParent = getOffsetParent(el);
var ps = {

@@ -194,3 +173,3 @@ x: el.offsetLeft,

return ps;
}
} // get position of a el if its offset is given. like jQuery.offset.
function backupAttr(el, name) {

@@ -765,3 +744,3 @@ var key = "original_".concat(name);

return {
position: offsetToPosition(el, getOffset(el0)),
position: getPosition(el),
el: el

@@ -768,0 +747,0 @@ };

/*!
* draggable-helper v1.0.17
* draggable-helper v1.0.18
* (c) 2018-present phphe <phphe@outlook.com> (https://github.com/phphe)
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.draggableHelper=t()}(this,function(){"use strict";function e(e){var t=e.getBoundingClientRect(),n=function(){if("undefined"!=typeof pageYOffset)return{top:pageYOffset,left:pageXOffset};var e=document.body,t=document.documentElement;return{top:(t=t.clientHeight?t:e).scrollTop,left:t.scrollLeft}}();return{x:t.left+n.left,y:t.top+n.top}}function t(e,t){e["original_".concat(t)]=e.getAttribute(t)}function n(e,t){var n="original_".concat(t);e.setAttribute(t,e[n])}function o(e,t){(function(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)})(e,t)||(e.classList?e.classList.add(t):e.className+=" "+t)}function a(e,t,n){for(var o=arguments.length,a=new Array(o>3?o-3:0),r=3;r<o;r++)a[r-3]=arguments[r];e.addEventListener?e.addEventListener.apply(e,[t,n].concat(a)):e.attachEvent&&e.attachEvent.apply(e,["on".concat(t),n].concat(a))}function r(e,t,n){for(var o=arguments.length,a=new Array(o>3?o-3:0),r=3;r<o;r++)a[r-3]=arguments[r];e.removeEventListener?e.removeEventListener.apply(e,[t,n].concat(a)):e.detachEvent&&e.detachEvent.apply(e,["on".concat(t),n].concat(a))}var i={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},l={isTouch:function(e){return e.type&&e.type.startsWith("touch")},_getStore:function(e){return e._wrapperStore||(e._wrapperStore=[]),e._wrapperStore},on:function(e,t,n){var o,r,l=this,c=function(e){var o;if(l.isTouch(e))o={x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY};else if(o={x:e.pageX,y:e.pageY},"start"===t&&1!==e.which)return;return n.call(this,e,o)};this._getStore(e).push({handler:n,wrapper:c});for(var s=arguments.length,u=new Array(s>3?s-3:0),f=3;f<s;f++)u[f-3]=arguments[f];(o=a).call.apply(o,[null,e,i[t][0],c].concat(u)),(r=a).call.apply(r,[null,e,i[t][1],c].concat(u))},off:function(e,t,n){for(var o=this._getStore(e),a=arguments.length,l=new Array(a>3?a-3:0),c=3;c<a;c++)l[c-3]=arguments[c];for(var s=o.length-1;s>=0;s--){var u,f,p=o[s],d=p.handler,v=p.wrapper;if(n===d)(u=r).call.apply(u,[null,e,i[t][0],v].concat(l)),(f=r).call.apply(f,[null,e,i[t][1],v].concat(l)),o.splice(s,1)}}};return function(i){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null==c.minTranslate&&(c.minTranslate=10);var s={movedCount:0},u=function(){l.off(i,"end",i._draggbleEventHandler),r(i,"selectstart",v),delete i._draggbleEventHandler};return i._draggbleEventHandler&&u(),i._draggbleEventHandler=function(e,t){s.mouse={x:t.x,y:t.y},s.initialMouse=Object.assign({},s.mouse),l.on(document,"move",p,{passive:!1}),l.on(window,"end",d)},l.on(i,"start",i._draggbleEventHandler),a(i,"selectstart",v),u;function f(n){var a=function(){var t=c.getEl?c.getEl(i,c):i,n=t;return c.clone&&(s.triggerEl=t,n=t.cloneNode(!0),t.parentElement.appendChild(n)),{position:function(e,t){var n=e.offsetParent;(!n||n===document.body&&"static"===getComputedStyle(document.body).position)&&(n=document.body.parentElement);for(var o={x:e.offsetLeft,y:e.offsetTop},a=e;(a=a.parentElement)!==n&&a;)o.x-=a.scrollLeft,o.y-=a.scrollTop;return o}(n,e(t)),el:n}}(),r=a.el,l=a.position;if(s.el=r,s.initialPosition=Object.assign({},l),!1===(c.drag&&c.drag(n,c,s)))return!1;var u=function(e){var t=e.style.display;e.style.display="block";var n={width:e.offsetWidth,height:e.offsetHeight};return e.style.display=t,n}(r),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"},c.style||c.getStyle&&c.getStyle(c)||{});for(var p in t(r,"style"),f)r.style[p]=f[p];t(r,"class"),o(r,c.draggingClass)}function p(e,t){s.mouse={x:t.x,y:t.y};var n=s.move={x:s.mouse.x-s.initialMouse.x,y:s.mouse.y-s.initialMouse.y};if(0===s.movedCount&&c.minTranslate){var o=Math.pow(s.move.x,2),a=Math.pow(s.move.y,2);if(Math.pow(o+a,.5)<c.minTranslate)return}var r=!0;if(0===s.movedCount&&!1===f(e)&&(r=!1),e.preventDefault(),r&&c.moving&&!1===c.moving(e,c,s)&&(r=!1),r){if(!s||!s.el)return;Object.assign(s.el.style,{left:s.initialPosition.x+n.x+"px",top:s.initialPosition.y+n.y+"px"}),s.movedCount++}}function d(e){if(l.off(document,"move",p),l.off(window,"end",d),s.movedCount>0){s.movedCount=0;var t=s.el;c.clone?t.parentElement.removeChild(t):(n(t,"style"),n(t,"class")),c.drop&&c.drop(e,c,s)}s={movedCount:0}}function v(e){e.preventDefault()}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.draggableHelper=t()}(this,function(){"use strict";function e(e){for(var t=function(e){var t=e.offsetParent;return(!t||t===document.body&&"static"===getComputedStyle(document.body).position)&&(t=document.body.parentElement),t}(e),n={x:e.offsetLeft,y:e.offsetTop},o=e;(o=o.parentElement)!==t&&o;)n.x-=o.scrollLeft,n.y-=o.scrollTop;return n}function t(e,t){e["original_".concat(t)]=e.getAttribute(t)}function n(e,t){var n="original_".concat(t);e.setAttribute(t,e[n])}function o(e,t){(function(e,t){return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)})(e,t)||(e.classList?e.classList.add(t):e.className+=" "+t)}function a(e,t,n){for(var o=arguments.length,a=new Array(o>3?o-3:0),r=3;r<o;r++)a[r-3]=arguments[r];e.addEventListener?e.addEventListener.apply(e,[t,n].concat(a)):e.attachEvent&&e.attachEvent.apply(e,["on".concat(t),n].concat(a))}function r(e,t,n){for(var o=arguments.length,a=new Array(o>3?o-3:0),r=3;r<o;r++)a[r-3]=arguments[r];e.removeEventListener?e.removeEventListener.apply(e,[t,n].concat(a)):e.detachEvent&&e.detachEvent.apply(e,["on".concat(t),n].concat(a))}var i={start:["mousedown","touchstart"],move:["mousemove","touchmove"],end:["mouseup","touchend"]},l={isTouch:function(e){return e.type&&e.type.startsWith("touch")},_getStore:function(e){return e._wrapperStore||(e._wrapperStore=[]),e._wrapperStore},on:function(e,t,n){var o,r,l=this,s=function(e){var o;if(l.isTouch(e))o={x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY};else if(o={x:e.pageX,y:e.pageY},"start"===t&&1!==e.which)return;return n.call(this,e,o)};this._getStore(e).push({handler:n,wrapper:s});for(var c=arguments.length,u=new Array(c>3?c-3:0),p=3;p<c;p++)u[p-3]=arguments[p];(o=a).call.apply(o,[null,e,i[t][0],s].concat(u)),(r=a).call.apply(r,[null,e,i[t][1],s].concat(u))},off:function(e,t,n){for(var o=this._getStore(e),a=arguments.length,l=new Array(a>3?a-3:0),s=3;s<a;s++)l[s-3]=arguments[s];for(var c=o.length-1;c>=0;c--){var u,p,d=o[c],f=d.handler,v=d.wrapper;if(n===f)(u=r).call.apply(u,[null,e,i[t][0],v].concat(l)),(p=r).call.apply(p,[null,e,i[t][1],v].concat(l)),o.splice(c,1)}}};return function(i){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null==s.minTranslate&&(s.minTranslate=10);var c={movedCount:0},u=function(){l.off(i,"end",i._draggbleEventHandler),r(i,"selectstart",v),delete i._draggbleEventHandler};return i._draggbleEventHandler&&u(),i._draggbleEventHandler=function(e,t){c.mouse={x:t.x,y:t.y},c.initialMouse=Object.assign({},c.mouse),l.on(document,"move",d,{passive:!1}),l.on(window,"end",f)},l.on(i,"start",i._draggbleEventHandler),a(i,"selectstart",v),u;function p(n){var a=function(){var t=s.getEl?s.getEl(i,s):i,n=t;return s.clone&&(c.triggerEl=t,n=t.cloneNode(!0),t.parentElement.appendChild(n)),{position:e(n),el:n}}(),r=a.el,l=a.position;if(c.el=r,c.initialPosition=Object.assign({},l),!1===(s.drag&&s.drag(n,s,c)))return!1;var u=function(e){var t=e.style.display;e.style.display="block";var n={width:e.offsetWidth,height:e.offsetHeight};return e.style.display=t,n}(r),p=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"},s.style||s.getStyle&&s.getStyle(s)||{});for(var d in t(r,"style"),p)r.style[d]=p[d];t(r,"class"),o(r,s.draggingClass)}function d(e,t){c.mouse={x:t.x,y:t.y};var n=c.move={x:c.mouse.x-c.initialMouse.x,y:c.mouse.y-c.initialMouse.y};if(0===c.movedCount&&s.minTranslate){var o=Math.pow(c.move.x,2),a=Math.pow(c.move.y,2);if(Math.pow(o+a,.5)<s.minTranslate)return}var r=!0;if(0===c.movedCount&&!1===p(e)&&(r=!1),e.preventDefault(),r&&s.moving&&!1===s.moving(e,s,c)&&(r=!1),r){if(!c||!c.el)return;Object.assign(c.el.style,{left:c.initialPosition.x+n.x+"px",top:c.initialPosition.y+n.y+"px"}),c.movedCount++}}function f(e){if(l.off(document,"move",d),l.off(window,"end",f),c.movedCount>0){c.movedCount=0;var t=c.el;s.clone?t.parentElement.removeChild(t):(n(t,"style"),n(t,"class")),s.drop&&s.drop(e,s,c)}c={movedCount:0}}function v(e){e.preventDefault()}}});
//# sourceMappingURL=draggable-helper.min.js.map
{
"name": "draggable-helper",
"version": "1.0.17",
"version": "1.0.18",
"description": "",

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

"drag-event-service": "0.0.6",
"helper-js": "^1.2.0"
"helper-js": "^1.3.0"
},
"license": "MIT"
}

@@ -1,2 +0,2 @@

import { onDOM, offDOM, getElSize, backupAttr, restoreAttr, getOffset, offsetToPosition, addClass } from 'helper-js'
import * as hp from 'helper-js'
import DragEventService from 'drag-event-service'

@@ -46,3 +46,3 @@

DragEventService.off(dragHandlerEl, 'end', dragHandlerEl._draggbleEventHandler)
offDOM(dragHandlerEl, 'selectstart', preventSelect)
hp.offDOM(dragHandlerEl, 'selectstart', preventSelect)
delete dragHandlerEl._draggbleEventHandler

@@ -55,3 +55,3 @@ }

DragEventService.on(dragHandlerEl, 'start', dragHandlerEl._draggbleEventHandler)
onDOM(dragHandlerEl, 'selectstart', preventSelect)
hp.onDOM(dragHandlerEl, 'selectstart', preventSelect)
return destroy

@@ -77,3 +77,3 @@ function start(e, mouse) {

// dom actions
const size = getElSize(el)
const size = hp.getElSize(el)
const style = {

@@ -89,3 +89,3 @@ width: `${size.width}px`,

}
backupAttr(el, 'style')
hp.backupAttr(el, 'style')
for (const key in style) {

@@ -95,4 +95,4 @@ el.style[key] = style[key]

// add class
backupAttr(el, 'class')
addClass(el, opt.draggingClass)
hp.backupAttr(el, 'class')
hp.addClass(el, opt.draggingClass)
}

@@ -152,4 +152,4 @@ function moving(e, mouse) {

} else {
restoreAttr(el, 'style')
restoreAttr(el, 'class')
hp.restoreAttr(el, 'style')
hp.restoreAttr(el, 'class')
}

@@ -169,3 +169,3 @@ opt.drop && opt.drop(e, opt, store)

return {
position: offsetToPosition(el, getOffset(el0)),
position: hp.getPosition(el),
el,

@@ -172,0 +172,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