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.11.0-rc to 0.11.0-rc2

2

declaration/Dragger.d.ts

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

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

@@ -26,0 +26,0 @@ onDragEnd: (e: any) => void;

@@ -22,2 +22,3 @@ import { IObject } from "@daybrush/utils";

datas: IObject<any>;
isScroll: boolean;
inputEvent: any;

@@ -24,0 +25,0 @@ }

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

repository: git+https://github.com/daybrush/drag.git
version: 0.11.0-rc
version: 0.11.0-rc2
*/

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

this.onDrag = function (e) {
this.onDrag = function (e, isScroll) {
if (!_this.flag) {

@@ -213,2 +213,3 @@ return;

drag && drag(__assign({}, result, {
isScroll: !!isScroll,
inputEvent: e

@@ -290,3 +291,3 @@ }));

});
this.onDrag(e);
this.onDrag(e, true);
};

@@ -320,2 +321,3 @@

}, position, {
isScroll: false,
inputEvent: inputEvent

@@ -322,0 +324,0 @@ });

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

repository: git+https://github.com/daybrush/drag.git
version: 0.11.0-rc
version: 0.11.0-rc2
*/

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

this.onDrag = function (e) {
this.onDrag = function (e, isScroll) {
if (!_this.flag) {

@@ -211,2 +211,3 @@ return;

drag && drag(__assign({}, result, {
isScroll: !!isScroll,
inputEvent: e

@@ -288,3 +289,3 @@ }));

});
this.onDrag(e);
this.onDrag(e, true);
};

@@ -318,2 +319,3 @@

}, position, {
isScroll: false,
inputEvent: inputEvent

@@ -320,0 +322,0 @@ });

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

repository: git+https://github.com/daybrush/drag.git
version: 0.11.0-rc
version: 0.11.0-rc2
*/

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

this.onDrag = function (e) {
this.onDrag = function (e, isScroll) {
if (!_this.flag) {

@@ -260,2 +260,3 @@ return;

drag && drag(__assign({}, result, {
isScroll: !!isScroll,
inputEvent: e

@@ -337,3 +338,3 @@ }));

});
this.onDrag(e);
this.onDrag(e, true);
};

@@ -367,2 +368,3 @@

}, position, {
isScroll: false,
inputEvent: inputEvent

@@ -369,0 +371,0 @@ });

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

repository: git+https://github.com/daybrush/drag.git
version: 0.11.0-rc
version: 0.11.0-rc2
*/
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).Dragger=i()}(this,function(){"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 f(t,i,n,s){var e=d(t),a=d(i),r=d(s);return p(h(s[0],c(e,r)),h(s[0],c(a,r)),n[0])}function r(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 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 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 h(t,i){return{clientX:t.clientX+i.clientX,clientY:t.clientY+i.clientY}}function c(t,i){return{clientX:t.clientX-i.clientX,clientY:t.clientY-i.clientY}}function o(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:r(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(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=r(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?f(n,n,s,a.startPinchClients):p(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&&(o(t,"mousedown",this.onDragStart),o(s,"mousemove",this.onDrag),o(s,"mouseup",this.onDragEnd)),this.isTouch&&(o(t,"touchstart",this.onDragStart),o(s,"touchmove",this.onDrag),o(s,"touchend",this.onDragEnd))}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(i,n,t){this.flag&&(this.startClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),this.onDrag(t))},i.move=function(t,i,n){var s=t[0],e=t[1];void 0===n&&(n=this.prevClients);var a=this.customDist,r=this.prevClients,h=this.startClients,c=this.pinchFlag?f(n,r,h,this.startPinchClients):p(n[0],r[0],h[0]);a[0]+=s,a[1]+=e,c.deltaX+=s,c.deltaY+=e;var o=c.deltaX,l=c.deltaY;return c.distX+=a[0],c.distY+=a[1],this.movement+=Math.sqrt(o*o+l*l),this.prevClients=n,this.isDrag=!0,u({datas:this.datas},c,{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 r=g(t.changedTouches);if(this.pinchFlag=!0,(i=this.startClients).push.apply(i,r),(n=this.prevClients).push.apply(n,r),this.startDistance=l(this.prevClients),this.startPinchClients=this.prevClients.slice(),e){var h=this.prevClients,c=d(h),o=p(c,c,c);e(u({datas:this.datas,touches:v(h,h,h)},o,{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)),r=l(i);n(u({datas:this.datas,touches:v(i,s,e),scale:r/this.startDistance,distance:r},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(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}();var t={default:s,drag:function(t,i){return new s(t,i)}};for(var i in t)s[i]=t[i];return s});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).Dragger=i()}(this,function(){"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 f(t,i,n,s){var e=d(t),a=d(i),r=d(s);return p(h(s[0],c(e,r)),h(s[0],c(a,r)),n[0])}function r(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 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 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 h(t,i){return{clientX:t.clientX+i.clientX,clientY:t.clientY+i.clientY}}function c(t,i){return{clientX:t.clientX-i.clientX,clientY:t.clientY-i.clientY}}function o(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:r(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(u({datas:a.datas,inputEvent:t},n))))&&(a.startClients=[],a.prevClients=[],a.flag=!1),a.flag&&t.preventDefault()}}},this.onDrag=function(t,i){if(a.flag){var n=r(t);a.pinchFlag&&a.onPinch(t,n);var s=a.move([0,0],t,n);if(s&&(s.deltaX||s.deltaY)){var e=a.options.drag;e&&e(u({},s,{isScroll:!!i,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?f(n,n,s,a.startPinchClients):p(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&&(o(t,"mousedown",this.onDragStart),o(s,"mousemove",this.onDrag),o(s,"mouseup",this.onDragEnd)),this.isTouch&&(o(t,"touchstart",this.onDragStart),o(s,"touchmove",this.onDrag),o(s,"touchend",this.onDragEnd))}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(i,n,t){this.flag&&(this.startClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),this.onDrag(t,!0))},i.move=function(t,i,n){var s=t[0],e=t[1];void 0===n&&(n=this.prevClients);var a=this.customDist,r=this.prevClients,h=this.startClients,c=this.pinchFlag?f(n,r,h,this.startPinchClients):p(n[0],r[0],h[0]);a[0]+=s,a[1]+=e,c.deltaX+=s,c.deltaY+=e;var o=c.deltaX,l=c.deltaY;return c.distX+=a[0],c.distY+=a[1],this.movement+=Math.sqrt(o*o+l*l),this.prevClients=n,this.isDrag=!0,u({datas:this.datas},c,{isScroll:!1,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 r=g(t.changedTouches);if(this.pinchFlag=!0,(i=this.startClients).push.apply(i,r),(n=this.prevClients).push.apply(n,r),this.startDistance=l(this.prevClients),this.startPinchClients=this.prevClients.slice(),e){var h=this.prevClients,c=d(h),o=p(c,c,c);e(u({datas:this.datas,touches:v(h,h,h)},o,{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)),r=l(i);n(u({datas:this.datas,touches:v(i,s,e),scale:r/this.startDistance,distance:r},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(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}();var t={default:s,drag:function(t,i){return new s(t,i)}};for(var i in t)s[i]=t[i];return s});
//# sourceMappingURL=drag.min.js.map
{
"name": "@daybrush/drag",
"version": "0.11.0-rc",
"version": "0.11.0-rc2",
"description": "You can set up drag events in any browser.",

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

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

});
this.onDrag(e);
this.onDrag(e, true);
}

@@ -116,3 +116,3 @@ public onDragStart = (e: any) => {

}
public onDrag = (e: any) => {
public onDrag = (e: any, isScroll?: boolean) => {
if (!this.flag) {

@@ -135,2 +135,3 @@ return;

...result,
isScroll: !!isScroll,
inputEvent: e,

@@ -167,2 +168,3 @@ });

...position,
isScroll: false,
inputEvent,

@@ -169,0 +171,0 @@ };

@@ -22,2 +22,3 @@ import { IObject } from "@daybrush/utils";

datas: IObject<any>;
isScroll: boolean;
inputEvent: any;

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