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

@daybrush/drag

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daybrush/drag - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

2

declaration/Dragger.d.ts

@@ -23,3 +23,3 @@ import { DragOptions, Client, OnDrag } from "./types";

onDrag: (e: any) => void;
move([deltaX, deltaY]: number[], clients?: Client[]): OnDrag | undefined;
move([deltaX, deltaY]: number[], inputEvent: any, clients?: Client[]): OnDrag | undefined;
onDragEnd: (e: any) => void;

@@ -26,0 +26,0 @@ onPinchStart(e: TouchEvent): void;

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/drag.git
version: 0.10.0
version: 0.10.1
*/

@@ -204,3 +204,3 @@ 'use strict';

var result = _this.move([0, 0], clients);
var result = _this.move([0, 0], e, clients);

@@ -276,3 +276,3 @@ if (!result || !result.deltaX && !result.deltaY) {

__proto.move = function (_a, clients) {
__proto.move = function (_a, inputEvent, clients) {
var deltaX = _a[0],

@@ -303,3 +303,3 @@ deltaY = _a[1];

}, position, {
inputEvent: null
inputEvent: inputEvent
});

@@ -306,0 +306,0 @@ };

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/drag.git
version: 0.10.0
version: 0.10.1
*/

@@ -202,3 +202,3 @@ import { removeEvent, addEvent } from '@daybrush/utils';

var result = _this.move([0, 0], clients);
var result = _this.move([0, 0], e, clients);

@@ -274,3 +274,3 @@ if (!result || !result.deltaX && !result.deltaY) {

__proto.move = function (_a, clients) {
__proto.move = function (_a, inputEvent, clients) {
var deltaX = _a[0],

@@ -301,3 +301,3 @@ deltaY = _a[1];

}, position, {
inputEvent: null
inputEvent: inputEvent
});

@@ -304,0 +304,0 @@ };

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/drag.git
version: 0.10.0
version: 0.10.1
*/

@@ -251,3 +251,3 @@ (function (global, factory) {

var result = _this.move([0, 0], clients);
var result = _this.move([0, 0], e, clients);

@@ -323,3 +323,3 @@ if (!result || !result.deltaX && !result.deltaY) {

__proto.move = function (_a, clients) {
__proto.move = function (_a, inputEvent, clients) {
var deltaX = _a[0],

@@ -350,3 +350,3 @@ deltaY = _a[1];

}, position, {
inputEvent: null
inputEvent: inputEvent
});

@@ -353,0 +353,0 @@ };

@@ -7,5 +7,5 @@ /*

repository: git+https://github.com/daybrush/drag.git
version: 0.10.0
version: 0.10.1
*/
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t=t||self).Dragger={})}(this,function(t){"use strict";var l=function(){return(l=Object.assign||function(t){for(var i,n=1,s=arguments.length;n<s;n++)for(var e in i=arguments[n])Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e]);return t}).apply(this,arguments)};function u(t,i,n,s){var e=d(t),a=d(i),h=d(s);return p(r(s[0],o(e,h)),r(s[0],o(a,h)),n[0])}function h(t){return t.touches?g(t.touches):[e(t)]}function p(t,i,n){var s=t.clientX,e=t.clientY;return{clientX:s,clientY:e,deltaX:s-i.clientX,deltaY:e-i.clientY,distX:s-n.clientX,distY:e-n.clientY}}function f(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function v(t,n,s){return t.map(function(t,i){return p(t,n[i],s[i])})}function g(t){for(var i=Math.min(t.length,2),n=[],s=0;s<i;++s)n.push(e(t[s]));return n}function e(t){return{clientX:t.clientX,clientY:t.clientY}}function d(t){return{clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function r(t,i){return{clientX:t.clientX+i.clientX,clientY:t.clientY+i.clientY}}function o(t,i){return{clientX:t.clientX-i.clientX,clientY:t.clientY-i.clientY}}function c(t,i,n,s){t.addEventListener(i,n,s)}function n(t,i,n){t.removeEventListener(i,n)}var s=function(){function t(t,i){var a=this;void 0===i&&(i={}),this.el=t,this.options={},this.flag=!1,this.pinchFlag=!1,this.datas={},this.isDrag=!1,this.isPinch=!1,this.isMouse=!1,this.isTouch=!1,this.prevClients=[],this.startClients=[],this.movement=0,this.startPinchClients=[],this.startDistance=0,this.customDist=[0,0],this.onDragStart=function(t){if(a.flag||!1!==t.cancelable){if(function(t){return t.touches&&2<=t.touches.length}(t)){if(!a.flag&&t.touches.length!==t.changedTouches.length)return;a.pinchFlag||a.onPinchStart(t)}if(!a.flag){var i=a.startClients[0]?a.startClients:h(t);a.customDist=[0,0],a.flag=!0,a.isDrag=!1,a.startClients=i,a.prevClients=i,a.datas={};var n=p(i[a.movement=0],a.prevClients[0],a.startClients[0]),s=a.options,e=s.dragstart;(s.preventRightClick&&3===t.which||!1===(e&&e(l({datas:a.datas,inputEvent:t},n))))&&(a.startClients=[],a.prevClients=[],a.flag=!1),a.flag&&t.preventDefault()}}},this.onDrag=function(t){if(a.flag){var i=h(t);a.pinchFlag&&a.onPinch(t,i);var n=a.move([0,0],i);if(n&&(n.deltaX||n.deltaY)){var s=a.options.drag;s&&s(l({},n,{inputEvent:t}))}}},this.onDragEnd=function(t){if(a.flag){a.pinchFlag&&a.onPinchEnd(t),a.flag=!1;var i=a.options.dragend,n=a.prevClients,s=a.startClients,e=a.pinchFlag?u(n,n,s,a.startPinchClients):p(n[0],n[0],s[0]);a.startClients=[],a.prevClients=[],i&&i(l({datas:a.datas,isDrag:a.isDrag,inputEvent:t},e))}},this.options=l({container:t,preventRightClick:!0,pinchThreshold:0,events:["touch","mouse"]},i);var n=this.options,s=n.container,e=n.events;this.isTouch=-1<e.indexOf("touch"),this.isMouse=-1<e.indexOf("mouse"),this.customDist=[0,0],this.isMouse&&(c(t,"mousedown",this.onDragStart),c(s,"mousemove",this.onDrag),c(s,"mouseup",this.onDragEnd)),this.isTouch&&(c(t,"touchstart",this.onDragStart),c(s,"touchmove",this.onDrag),c(s,"touchend",this.onDragEnd))}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isPinching=function(){return this.isPinch},i.move=function(t,i){var n=t[0],s=t[1];void 0===i&&(i=this.prevClients);var e=this.customDist,a=this.prevClients,h=this.startClients,r=this.pinchFlag?u(i,a,h,this.startPinchClients):p(i[0],a[0],h[0]);e[0]+=n,e[1]+=s,r.deltaX+=n,r.deltaY+=s;var o=r.deltaX,c=r.deltaY;return r.distX+=e[0],r.distY+=e[1],this.movement+=Math.sqrt(o*o+c*c),this.prevClients=i,this.isDrag=!0,l({datas:this.datas},r,{inputEvent:null})},i.onPinchStart=function(t){var i,n,s=this.options,e=s.pinchstart,a=s.pinchThreshold;if(!(this.isDrag&&this.movement>a)){var h=g(t.changedTouches);if(this.pinchFlag=!0,(i=this.startClients).push.apply(i,h),(n=this.prevClients).push.apply(n,h),this.startDistance=f(this.prevClients),this.startPinchClients=this.prevClients.slice(),e){var r=this.prevClients,o=d(r),c=p(o,o,o);e(l({datas:this.datas,touches:v(r,r,r)},c,{inputEvent:t}))}}},i.onPinch=function(t,i){if(this.flag&&this.pinchFlag){this.isPinch=!0;var n=this.options.pinch;if(n){var s=this.prevClients,e=this.startClients,a=p(d(i),d(s),d(e)),h=f(i);n(l({datas:this.datas,touches:v(i,s,e),scale:h/this.startDistance,distance:h},a,{inputEvent:t}))}}},i.onPinchEnd=function(t){if(this.flag&&this.pinchFlag){var i=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.options.pinchend;if(n){var s=this.prevClients,e=this.startClients,a=p(d(s),d(s),d(e));n(l({datas:this.datas,isPinch:i,touches:v(s,s,e)},a,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},i.unset=function(){var t=this.el,i=this.options.container;this.isMouse&&(n(t,"mousedown",this.onDragStart),n(i,"mousemove",this.onDrag),n(i,"mouseup",this.onDragEnd)),this.isTouch&&(n(t,"touchstart",this.onDragStart),n(i,"touchmove",this.onDrag),n(i,"touchend",this.onDragEnd))},t}();t.default=s,t.drag=function(t,i){return new s(t,i)}});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t=t||self).Dragger={})}(this,function(t){"use strict";var u=function(){return(u=Object.assign||function(t){for(var i,n=1,s=arguments.length;n<s;n++)for(var e in i=arguments[n])Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e]);return t}).apply(this,arguments)};function p(t,i,n,s){var e=d(t),a=d(i),h=d(s);return f(r(s[0],o(e,h)),r(s[0],o(a,h)),n[0])}function h(t){return t.touches?g(t.touches):[e(t)]}function f(t,i,n){var s=t.clientX,e=t.clientY;return{clientX:s,clientY:e,deltaX:s-i.clientX,deltaY:e-i.clientY,distX:s-n.clientX,distY:e-n.clientY}}function l(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function v(t,n,s){return t.map(function(t,i){return f(t,n[i],s[i])})}function g(t){for(var i=Math.min(t.length,2),n=[],s=0;s<i;++s)n.push(e(t[s]));return n}function e(t){return{clientX:t.clientX,clientY:t.clientY}}function d(t){return{clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function r(t,i){return{clientX:t.clientX+i.clientX,clientY:t.clientY+i.clientY}}function o(t,i){return{clientX:t.clientX-i.clientX,clientY:t.clientY-i.clientY}}function c(t,i,n,s){t.addEventListener(i,n,s)}function n(t,i,n){t.removeEventListener(i,n)}var s=function(){function t(t,i){var a=this;void 0===i&&(i={}),this.el=t,this.options={},this.flag=!1,this.pinchFlag=!1,this.datas={},this.isDrag=!1,this.isPinch=!1,this.isMouse=!1,this.isTouch=!1,this.prevClients=[],this.startClients=[],this.movement=0,this.startPinchClients=[],this.startDistance=0,this.customDist=[0,0],this.onDragStart=function(t){if(a.flag||!1!==t.cancelable){if(function(t){return t.touches&&2<=t.touches.length}(t)){if(!a.flag&&t.touches.length!==t.changedTouches.length)return;a.pinchFlag||a.onPinchStart(t)}if(!a.flag){var i=a.startClients[0]?a.startClients:h(t);a.customDist=[0,0],a.flag=!0,a.isDrag=!1,a.startClients=i,a.prevClients=i,a.datas={};var n=f(i[a.movement=0],a.prevClients[0],a.startClients[0]),s=a.options,e=s.dragstart;(s.preventRightClick&&3===t.which||!1===(e&&e(u({datas:a.datas,inputEvent:t},n))))&&(a.startClients=[],a.prevClients=[],a.flag=!1),a.flag&&t.preventDefault()}}},this.onDrag=function(t){if(a.flag){var i=h(t);a.pinchFlag&&a.onPinch(t,i);var n=a.move([0,0],t,i);if(n&&(n.deltaX||n.deltaY)){var s=a.options.drag;s&&s(u({},n,{inputEvent:t}))}}},this.onDragEnd=function(t){if(a.flag){a.pinchFlag&&a.onPinchEnd(t),a.flag=!1;var i=a.options.dragend,n=a.prevClients,s=a.startClients,e=a.pinchFlag?p(n,n,s,a.startPinchClients):f(n[0],n[0],s[0]);a.startClients=[],a.prevClients=[],i&&i(u({datas:a.datas,isDrag:a.isDrag,inputEvent:t},e))}},this.options=u({container:t,preventRightClick:!0,pinchThreshold:0,events:["touch","mouse"]},i);var n=this.options,s=n.container,e=n.events;this.isTouch=-1<e.indexOf("touch"),this.isMouse=-1<e.indexOf("mouse"),this.customDist=[0,0],this.isMouse&&(c(t,"mousedown",this.onDragStart),c(s,"mousemove",this.onDrag),c(s,"mouseup",this.onDragEnd)),this.isTouch&&(c(t,"touchstart",this.onDragStart),c(s,"touchmove",this.onDrag),c(s,"touchend",this.onDragEnd))}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isPinching=function(){return this.isPinch},i.move=function(t,i,n){var s=t[0],e=t[1];void 0===n&&(n=this.prevClients);var a=this.customDist,h=this.prevClients,r=this.startClients,o=this.pinchFlag?p(n,h,r,this.startPinchClients):f(n[0],h[0],r[0]);a[0]+=s,a[1]+=e,o.deltaX+=s,o.deltaY+=e;var c=o.deltaX,l=o.deltaY;return o.distX+=a[0],o.distY+=a[1],this.movement+=Math.sqrt(c*c+l*l),this.prevClients=n,this.isDrag=!0,u({datas:this.datas},o,{inputEvent:i})},i.onPinchStart=function(t){var i,n,s=this.options,e=s.pinchstart,a=s.pinchThreshold;if(!(this.isDrag&&this.movement>a)){var h=g(t.changedTouches);if(this.pinchFlag=!0,(i=this.startClients).push.apply(i,h),(n=this.prevClients).push.apply(n,h),this.startDistance=l(this.prevClients),this.startPinchClients=this.prevClients.slice(),e){var r=this.prevClients,o=d(r),c=f(o,o,o);e(u({datas:this.datas,touches:v(r,r,r)},c,{inputEvent:t}))}}},i.onPinch=function(t,i){if(this.flag&&this.pinchFlag){this.isPinch=!0;var n=this.options.pinch;if(n){var s=this.prevClients,e=this.startClients,a=f(d(i),d(s),d(e)),h=l(i);n(u({datas:this.datas,touches:v(i,s,e),scale:h/this.startDistance,distance:h},a,{inputEvent:t}))}}},i.onPinchEnd=function(t){if(this.flag&&this.pinchFlag){var i=this.isPinch;this.isPinch=!1,this.pinchFlag=!1;var n=this.options.pinchend;if(n){var s=this.prevClients,e=this.startClients,a=f(d(s),d(s),d(e));n(u({datas:this.datas,isPinch:i,touches:v(s,s,e)},a,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},i.unset=function(){var t=this.el,i=this.options.container;this.isMouse&&(n(t,"mousedown",this.onDragStart),n(i,"mousemove",this.onDrag),n(i,"mouseup",this.onDragEnd)),this.isTouch&&(n(t,"touchstart",this.onDragStart),n(i,"touchmove",this.onDrag),n(i,"touchend",this.onDragEnd))},t}();t.default=s,t.drag=function(t,i){return new s(t,i)}});
//# sourceMappingURL=drag.min.js.map
{
"name": "@daybrush/drag",
"version": "0.10.0",
"version": "0.10.1",
"description": "You can set up drag events in any browser.",

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

@@ -110,3 +110,3 @@ import { DragOptions, Client, Position, Delta, OnDrag } from "./types";

}
const result = this.move([0, 0], clients);
const result = this.move([0, 0], e, clients);

@@ -123,3 +123,3 @@ if (!result || (!result.deltaX && !result.deltaY)) {

}
public move([deltaX, deltaY]: number[], clients = this.prevClients): OnDrag | undefined {
public move([deltaX, deltaY]: number[], inputEvent: any, clients = this.prevClients): OnDrag | undefined {
const customDist = this.customDist;

@@ -152,3 +152,3 @@ const prevClients = this.prevClients;

...position,
inputEvent: null,
inputEvent,
};

@@ -155,0 +155,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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