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.7.0 to 0.8.0

1

declaration/types.d.ts

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

scale: number;
distance: number;
inputEvent: any;

@@ -40,0 +41,0 @@ }

7

dist/drag.cjs.js

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

repository: git+https://github.com/daybrush/drag.git
version: 0.7.0
version: 0.8.0
*/

@@ -306,6 +306,9 @@ 'use strict';

var centerPosition = getPosition(getAverageClient(clients), getAverageClient(prevClients), getAverageClient(startClients));
var distance = getDist(clients);
var startDistance = getDist(startClients);
pinch(__assign({
datas: this.datas,
touches: getPositions(clients, prevClients, startClients),
scale: getDist(clients) / getDist(startClients)
scale: distance / startDistance,
distance: distance
}, centerPosition, {

@@ -312,0 +315,0 @@ inputEvent: e

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

repository: git+https://github.com/daybrush/drag.git
version: 0.7.0
version: 0.8.0
*/

@@ -304,6 +304,9 @@ import { removeEvent, addEvent } from '@daybrush/utils';

var centerPosition = getPosition(getAverageClient(clients), getAverageClient(prevClients), getAverageClient(startClients));
var distance = getDist(clients);
var startDistance = getDist(startClients);
pinch(__assign({
datas: this.datas,
touches: getPositions(clients, prevClients, startClients),
scale: getDist(clients) / getDist(startClients)
scale: distance / startDistance,
distance: distance
}, centerPosition, {

@@ -310,0 +313,0 @@ inputEvent: e

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

repository: git+https://github.com/daybrush/drag.git
version: 0.7.0
version: 0.8.0
*/

@@ -353,6 +353,9 @@ (function (global, factory) {

var centerPosition = getPosition(getAverageClient(clients), getAverageClient(prevClients), getAverageClient(startClients));
var distance = getDist(clients);
var startDistance = getDist(startClients);
pinch(__assign({
datas: this.datas,
touches: getPositions(clients, prevClients, startClients),
scale: getDist(clients) / getDist(startClients)
scale: distance / startDistance,
distance: distance
}, centerPosition, {

@@ -359,0 +362,0 @@ inputEvent: e

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

repository: git+https://github.com/daybrush/drag.git
version: 0.7.0
version: 0.8.0
*/
!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 h=function(){return(h=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 o(t,i,n){var s=f(t),e=f(i),a=f(n);return l(g(n[0],v(s,a)),g(n[0],v(e,a)),n[0])}function c(t){return t.touches?p(t.touches):[e(t)]}function l(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 r(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function u(t,n,s){return t.map(function(t,i){return l(t,n[i],s[i])})}function p(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 f(t){return{clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function g(t,i){return{clientX:t.clientX+i.clientX,clientY:t.clientY+i.clientY}}function v(t,i){return{clientX:t.clientX-i.clientX,clientY:t.clientY-i.clientY}}function a(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 r=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.onDragStart=function(t){if(r.isDrag||!function(t){return t.touches&&2<=t.touches.length}(t)||r.pinchFlag||r.onPinchStart(t),!r.flag){var i=r.startClients[0]?r.startClients:c(t);r.flag=!0,r.isDrag=!1,r.startClients=i,r.prevClients=i,r.datas={};var n=l(i[0],r.prevClients[0],r.startClients[0]),s=r.options,e=s.dragstart;(s.preventRightClick&&3===t.which||!1===(e&&e(h({datas:r.datas,inputEvent:t},n))))&&(r.flag=!1),r.flag&&t.preventDefault()}},this.onDrag=function(t){if(r.flag){var i=c(t);r.pinchFlag&&r.onPinch(t,i);var n=r.prevClients,s=r.startClients,e=r.pinchFlag?o(i,n,s):l(i[0],n[0],s[0]);if(e.deltaX||e.deltaY){r.isDrag=!0;var a=r.options.drag;a&&a(h({datas:r.datas},e,{inputEvent:t})),r.prevClients=i}}},this.onDragEnd=function(t){if(r.flag){r.pinchFlag&&r.onPinchEnd(t),r.flag=!1;var i=r.options.dragend,n=r.prevClients,s=r.startClients,e=r.pinchFlag?o(n,n,s):l(n[0],n[0],s[0]);r.startClients=[],r.prevClients=[],i&&i(h({datas:r.datas,isDrag:r.isDrag,inputEvent:t},e))}},this.options=h({container:t,preventRightClick:!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.isMouse&&(a(t,"mousedown",this.onDragStart),a(s,"mousemove",this.onDrag),a(s,"mouseup",this.onDragEnd)),this.isTouch&&(a(t,"touchstart",this.onDragStart),a(s,"touchmove",this.onDrag),a(s,"touchend",this.onDragEnd))}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isPinching=function(){return this.isPinch},i.onPinchStart=function(t){var i,n;if(this.flag){this.pinchFlag=!0;var s=this.options.pinchstart,e=p(t.changedTouches);if((i=this.startClients).push.apply(i,e),(n=this.prevClients).push.apply(n,e),s){var a=this.startClients,r=f(a),o=l(r,r,r);s(h({datas:this.datas,touches:u(a,a,a)},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=l(f(i),f(s),f(e));n(h({datas:this.datas,touches:u(i,s,e),scale:r(i)/r(e)},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=l(f(s),f(s),f(e));n(h({datas:this.datas,isPinch:i,touches:u(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 h=function(){return(h=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 o(t,i,n){var s=g(t),e=g(i),a=g(n);return l(r(n[0],v(s,a)),r(n[0],v(e,a)),n[0])}function c(t){return t.touches?f(t.touches):[e(t)]}function l(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 u(t){return Math.sqrt(Math.pow(t[0].clientX-t[1].clientX,2)+Math.pow(t[0].clientY-t[1].clientY,2))}function p(t,n,s){return t.map(function(t,i){return l(t,n[i],s[i])})}function f(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 g(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 v(t,i){return{clientX:t.clientX-i.clientX,clientY:t.clientY-i.clientY}}function a(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 r=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.onDragStart=function(t){if(r.isDrag||!function(t){return t.touches&&2<=t.touches.length}(t)||r.pinchFlag||r.onPinchStart(t),!r.flag){var i=r.startClients[0]?r.startClients:c(t);r.flag=!0,r.isDrag=!1,r.startClients=i,r.prevClients=i,r.datas={};var n=l(i[0],r.prevClients[0],r.startClients[0]),s=r.options,e=s.dragstart;(s.preventRightClick&&3===t.which||!1===(e&&e(h({datas:r.datas,inputEvent:t},n))))&&(r.flag=!1),r.flag&&t.preventDefault()}},this.onDrag=function(t){if(r.flag){var i=c(t);r.pinchFlag&&r.onPinch(t,i);var n=r.prevClients,s=r.startClients,e=r.pinchFlag?o(i,n,s):l(i[0],n[0],s[0]);if(e.deltaX||e.deltaY){r.isDrag=!0;var a=r.options.drag;a&&a(h({datas:r.datas},e,{inputEvent:t})),r.prevClients=i}}},this.onDragEnd=function(t){if(r.flag){r.pinchFlag&&r.onPinchEnd(t),r.flag=!1;var i=r.options.dragend,n=r.prevClients,s=r.startClients,e=r.pinchFlag?o(n,n,s):l(n[0],n[0],s[0]);r.startClients=[],r.prevClients=[],i&&i(h({datas:r.datas,isDrag:r.isDrag,inputEvent:t},e))}},this.options=h({container:t,preventRightClick:!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.isMouse&&(a(t,"mousedown",this.onDragStart),a(s,"mousemove",this.onDrag),a(s,"mouseup",this.onDragEnd)),this.isTouch&&(a(t,"touchstart",this.onDragStart),a(s,"touchmove",this.onDrag),a(s,"touchend",this.onDragEnd))}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isPinching=function(){return this.isPinch},i.onPinchStart=function(t){var i,n;if(this.flag){this.pinchFlag=!0;var s=this.options.pinchstart,e=f(t.changedTouches);if((i=this.startClients).push.apply(i,e),(n=this.prevClients).push.apply(n,e),s){var a=this.startClients,r=g(a),o=l(r,r,r);s(h({datas:this.datas,touches:p(a,a,a)},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=l(g(i),g(s),g(e)),r=u(i),o=u(e);n(h({datas:this.datas,touches:p(i,s,e),scale:r/o,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=l(g(s),g(s),g(e));n(h({datas:this.datas,isPinch:i,touches:p(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.7.0",
"version": "0.8.0",
"description": "You can set up drag events in any browser.",

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

@@ -185,6 +185,9 @@ import { DragOptions, Client, Position } from "./types";

);
const distance = getDist(clients);
const startDistance = getDist(startClients);
pinch({
datas: this.datas,
touches: getPositions(clients, prevClients, startClients),
scale: getDist(clients) / getDist(startClients),
scale: distance / startDistance,
distance,
...centerPosition,

@@ -191,0 +194,0 @@ inputEvent: e,

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

scale: number;
distance: number;
inputEvent: any;

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