@daybrush/drag
Advanced tools
Comparing version 0.14.0 to 0.15.0
@@ -21,2 +21,3 @@ import { DragOptions, Client, OnDrag } from "./types"; | ||
isFlag(): boolean; | ||
isPinchFlag(): boolean; | ||
isPinching(): boolean; | ||
@@ -23,0 +24,0 @@ scrollBy(deltaX: number, deltaY: number, e: any, isCallDrag?: boolean): void; |
@@ -26,2 +26,3 @@ import { IObject } from "@daybrush/utils"; | ||
isPinch: boolean; | ||
movement: number; | ||
datas: IObject<any>; | ||
@@ -46,2 +47,3 @@ isScroll: boolean; | ||
distance: number; | ||
movement: number; | ||
inputEvent: any; | ||
@@ -48,0 +50,0 @@ } |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/drag.git | ||
version: 0.14.0 | ||
version: 0.15.0 | ||
*/ | ||
@@ -337,2 +337,10 @@ 'use strict'; | ||
__proto.isPinchFlag = function () { | ||
return this.pinchFlag; | ||
}; | ||
/** | ||
* | ||
*/ | ||
__proto.isPinching = function () { | ||
@@ -393,2 +401,3 @@ return this.isPinch; | ||
}, position, { | ||
movement: this.movement, | ||
isDrag: this.isDrag, | ||
@@ -457,2 +466,3 @@ isPinch: this.isPinch, | ||
datas: this.datas, | ||
movement: this.movement, | ||
touches: getPositions(clients, prevClients, startClients), | ||
@@ -459,0 +469,0 @@ scale: distance / this.startDistance, |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/drag.git | ||
version: 0.14.0 | ||
version: 0.15.0 | ||
*/ | ||
@@ -335,2 +335,10 @@ import { removeEvent, addEvent } from '@daybrush/utils'; | ||
__proto.isPinchFlag = function () { | ||
return this.pinchFlag; | ||
}; | ||
/** | ||
* | ||
*/ | ||
__proto.isPinching = function () { | ||
@@ -391,2 +399,3 @@ return this.isPinch; | ||
}, position, { | ||
movement: this.movement, | ||
isDrag: this.isDrag, | ||
@@ -455,2 +464,3 @@ isPinch: this.isPinch, | ||
datas: this.datas, | ||
movement: this.movement, | ||
touches: getPositions(clients, prevClients, startClients), | ||
@@ -457,0 +467,0 @@ scale: distance / this.startDistance, |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/drag.git | ||
version: 0.14.0 | ||
version: 0.15.0 | ||
*/ | ||
@@ -384,2 +384,10 @@ (function (global, factory) { | ||
__proto.isPinchFlag = function () { | ||
return this.pinchFlag; | ||
}; | ||
/** | ||
* | ||
*/ | ||
__proto.isPinching = function () { | ||
@@ -440,2 +448,3 @@ return this.isPinch; | ||
}, position, { | ||
movement: this.movement, | ||
isDrag: this.isDrag, | ||
@@ -504,2 +513,3 @@ isPinch: this.isPinch, | ||
datas: this.datas, | ||
movement: this.movement, | ||
touches: getPositions(clients, prevClients, startClients), | ||
@@ -506,0 +516,0 @@ scale: distance / this.startDistance, |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/drag.git | ||
version: 0.14.0 | ||
version: 0.15.0 | ||
*/ | ||
!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 l(t){return t.touches?d(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 g(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 d(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 1===t.length?t[0]:{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 C(t,i,n,s){t.addEventListener(i,n,s)}function m(t,i,n){t.removeEventListener(i,n)}var n=function(){function t(t,i){var o=this;void 0===i&&(i={}),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.targets=[],this.onDragStart=function(t){if(o.flag||!1!==t.cancelable){var i=o.options,n=i.container,s=i.pinchOutside,e=i.dragstart,a=i.preventRightClick,r=o.isTouch;if(!o.flag&&r&&s&&setTimeout(function(){C(n,"touchstart",o.onDragStart)}),o.flag&&r&&s&&m(n,"touchstart",o.onDragStart),function(t){return t.touches&&2<=t.touches.length}(t)){if(!o.flag&&t.touches.length!==t.changedTouches.length)return;o.pinchFlag||o.onPinchStart(t)}if(!o.flag){var h=o.startClients[0]?o.startClients:l(t);o.customDist=[0,0],o.flag=!0,o.isDrag=!1,o.startClients=h,o.prevClients=h,o.datas={};var c=p(h[o.movement=0],o.prevClients[0],o.startClients[0]);(a&&3===t.which||!1===(e&&e(u({type:"dragstart",datas:o.datas,inputEvent:t},c))))&&(o.startClients=[],o.prevClients=[],o.flag=!1),o.flag&&t.preventDefault()}}},this.onDrag=function(t,i){if(o.flag){var n=l(t);o.pinchFlag&&o.onPinch(t,n);var s=o.move([0,0],t,n);if(s&&(s.deltaX||s.deltaY)){var e=o.options.drag;e&&e(u({},s,{isScroll:!!i,inputEvent:t}))}}},this.onDragEnd=function(t){if(o.flag){var i=o.options,n=i.dragend,s=i.pinchOutside,e=i.container;o.isTouch&&s&&m(e,"touchstart",o.onDragStart),o.pinchFlag&&o.onPinchEnd(t),o.flag=!1;var a=o.prevClients,r=o.startClients,h=o.pinchFlag?f(a,a,r,o.startPinchClients):p(a[0],a[0],r[0]);o.startClients=[],o.prevClients=[],n&&n(u({type:"dragend",datas:o.datas,isDrag:o.isDrag,inputEvent:t},h))}};var n=[].concat(t);this.options=u({container:1<n.length?window:n[0],preventRightClick:!0,preventDefault:!0,pinchThreshold:0,events:["touch","mouse"]},i);var s=this.options,e=s.container,a=s.events;if(this.isTouch=-1<a.indexOf("touch"),this.isMouse=-1<a.indexOf("mouse"),this.customDist=[0,0],this.targets=n,this.isMouse&&(n.forEach(function(t){C(t,"mousedown",o.onDragStart)}),C(e,"mousemove",this.onDrag),C(e,"mouseup",this.onDragEnd)),this.isTouch){var r={passive:!1};n.forEach(function(t){C(t,"touchstart",o.onDragStart,r)}),C(e,"touchmove",this.onDrag,r),C(e,"touchend",this.onDragEnd,r),C(e,"touchcancel",this.onDragEnd,r)}}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isFlag=function(){return this.flag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(i,n,t,s){void 0===s&&(s=!0),this.flag&&(this.startClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),s&&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({type:"drag",datas:this.datas},c,{isDrag:this.isDrag,isPinch:this.isPinch,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=d(t.changedTouches);if(this.pinchFlag=!0,(i=this.startClients).push.apply(i,r),(n=this.prevClients).push.apply(n,r),this.startDistance=g(this.prevClients),this.startPinchClients=this.prevClients.slice(),e){var h=this.prevClients,c=D(h),o=p(c,c,c);e(u({type:"pinchstart",datas:this.datas,touches:v(h,h,h)},o,{inputEvent:t}))}}},i.onPinch=function(t,i){if(this.flag&&this.pinchFlag&&!(i.length<2)){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=g(i);n(u({type:"pinch",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({type:"pinchend",datas:this.datas,isPinch:i,touches:v(s,s,e)},a,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},i.unset=function(){var i=this,t=this.targets,n=this.options.container;this.isMouse&&(t.forEach(function(t){m(t,"mousedown",i.onDragStart)}),m(n,"mousemove",this.onDrag),m(n,"mouseup",this.onDragEnd)),this.isTouch&&(t.forEach(function(t){m(t,"touchstart",i.onDragStart)}),m(n,"touchstart",this.onDragStart),m(n,"touchmove",this.onDrag),m(n,"touchend",this.onDragEnd),m(n,"touchcancel",this.onDragEnd))},t}();var t={default:n,drag:function(t,i){return new n(t,i)}};for(var i in t)n[i]=t[i];return n}); | ||
!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 g(h(s[0],c(e,r)),h(s[0],c(a,r)),n[0])}function l(t){return t.touches?d(t.touches):[e(t)]}function g(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 p(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 g(t,n[i],s[i])})}function d(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 1===t.length?t[0]:{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 m(t,i,n,s){t.addEventListener(i,n,s)}function C(t,i,n){t.removeEventListener(i,n)}var n=function(){function t(t,i){var o=this;void 0===i&&(i={}),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.targets=[],this.onDragStart=function(t){if(o.flag||!1!==t.cancelable){var i=o.options,n=i.container,s=i.pinchOutside,e=i.dragstart,a=i.preventRightClick,r=o.isTouch;if(!o.flag&&r&&s&&setTimeout(function(){m(n,"touchstart",o.onDragStart)}),o.flag&&r&&s&&C(n,"touchstart",o.onDragStart),function(t){return t.touches&&2<=t.touches.length}(t)){if(!o.flag&&t.touches.length!==t.changedTouches.length)return;o.pinchFlag||o.onPinchStart(t)}if(!o.flag){var h=o.startClients[0]?o.startClients:l(t);o.customDist=[0,0],o.flag=!0,o.isDrag=!1,o.startClients=h,o.prevClients=h,o.datas={};var c=g(h[o.movement=0],o.prevClients[0],o.startClients[0]);(a&&3===t.which||!1===(e&&e(u({type:"dragstart",datas:o.datas,inputEvent:t},c))))&&(o.startClients=[],o.prevClients=[],o.flag=!1),o.flag&&t.preventDefault()}}},this.onDrag=function(t,i){if(o.flag){var n=l(t);o.pinchFlag&&o.onPinch(t,n);var s=o.move([0,0],t,n);if(s&&(s.deltaX||s.deltaY)){var e=o.options.drag;e&&e(u({},s,{isScroll:!!i,inputEvent:t}))}}},this.onDragEnd=function(t){if(o.flag){var i=o.options,n=i.dragend,s=i.pinchOutside,e=i.container;o.isTouch&&s&&C(e,"touchstart",o.onDragStart),o.pinchFlag&&o.onPinchEnd(t),o.flag=!1;var a=o.prevClients,r=o.startClients,h=o.pinchFlag?f(a,a,r,o.startPinchClients):g(a[0],a[0],r[0]);o.startClients=[],o.prevClients=[],n&&n(u({type:"dragend",datas:o.datas,isDrag:o.isDrag,inputEvent:t},h))}};var n=[].concat(t);this.options=u({container:1<n.length?window:n[0],preventRightClick:!0,preventDefault:!0,pinchThreshold:0,events:["touch","mouse"]},i);var s=this.options,e=s.container,a=s.events;if(this.isTouch=-1<a.indexOf("touch"),this.isMouse=-1<a.indexOf("mouse"),this.customDist=[0,0],this.targets=n,this.isMouse&&(n.forEach(function(t){m(t,"mousedown",o.onDragStart)}),m(e,"mousemove",this.onDrag),m(e,"mouseup",this.onDragEnd)),this.isTouch){var r={passive:!1};n.forEach(function(t){m(t,"touchstart",o.onDragStart,r)}),m(e,"touchmove",this.onDrag,r),m(e,"touchend",this.onDragEnd,r),m(e,"touchcancel",this.onDragEnd,r)}}var i=t.prototype;return i.isDragging=function(){return this.isDrag},i.isFlag=function(){return this.flag},i.isPinchFlag=function(){return this.pinchFlag},i.isPinching=function(){return this.isPinch},i.scrollBy=function(i,n,t,s){void 0===s&&(s=!0),this.flag&&(this.startClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),this.prevClients.forEach(function(t){t.clientX-=i,t.clientY-=n}),s&&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):g(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({type:"drag",datas:this.datas},c,{movement:this.movement,isDrag:this.isDrag,isPinch:this.isPinch,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=d(t.changedTouches);if(this.pinchFlag=!0,(i=this.startClients).push.apply(i,r),(n=this.prevClients).push.apply(n,r),this.startDistance=p(this.prevClients),this.startPinchClients=this.prevClients.slice(),e){var h=this.prevClients,c=D(h),o=g(c,c,c);e(u({type:"pinchstart",datas:this.datas,touches:v(h,h,h)},o,{inputEvent:t}))}}},i.onPinch=function(t,i){if(this.flag&&this.pinchFlag&&!(i.length<2)){this.isPinch=!0;var n=this.options.pinch;if(n){var s=this.prevClients,e=this.startClients,a=g(D(i),D(s),D(e)),r=p(i);n(u({type:"pinch",datas:this.datas,movement:this.movement,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=g(D(s),D(s),D(e));n(u({type:"pinchend",datas:this.datas,isPinch:i,touches:v(s,s,e)},a,{inputEvent:t})),this.isPinch=!1,this.pinchFlag=!1}}},i.unset=function(){var i=this,t=this.targets,n=this.options.container;this.isMouse&&(t.forEach(function(t){C(t,"mousedown",i.onDragStart)}),C(n,"mousemove",this.onDrag),C(n,"mouseup",this.onDragEnd)),this.isTouch&&(t.forEach(function(t){C(t,"touchstart",i.onDragStart)}),C(n,"touchstart",this.onDragStart),C(n,"touchmove",this.onDrag),C(n,"touchend",this.onDragEnd),C(n,"touchcancel",this.onDragEnd))},t}();var t={default:n,drag:function(t,i){return new n(t,i)}};for(var i in t)n[i]=t[i];return n}); | ||
//# sourceMappingURL=drag.min.js.map |
{ | ||
"name": "@daybrush/drag", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"description": "You can set up drag events in any browser.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/drag.cjs.js", |
@@ -82,2 +82,8 @@ import { DragOptions, Client, Position, OnDrag } from "./types"; | ||
*/ | ||
public isPinchFlag() { | ||
return this.pinchFlag; | ||
} | ||
/** | ||
* | ||
*/ | ||
public isPinching() { | ||
@@ -209,2 +215,3 @@ return this.isPinch; | ||
...position, | ||
movement: this.movement, | ||
isDrag: this.isDrag, | ||
@@ -299,2 +306,3 @@ isPinch: this.isPinch, | ||
datas: this.datas, | ||
movement: this.movement, | ||
touches: getPositions(clients, prevClients, startClients), | ||
@@ -301,0 +309,0 @@ scale: distance / this.startDistance, |
@@ -62,2 +62,3 @@ import { IObject } from "@daybrush/utils"; | ||
isPinch: boolean; | ||
movement: number; | ||
datas: IObject<any>; | ||
@@ -100,2 +101,3 @@ isScroll: boolean; | ||
distance: number; | ||
movement: number; | ||
inputEvent: any; | ||
@@ -102,0 +104,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
191595
2327