-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathangular-swipe-element.min.js
1 lines (1 loc) · 1.44 KB
/
angular-swipe-element.min.js
1
!function(a){function b(b){return{restrict:"EA",scope:{onMoveStart:"&swipeElementStart",onMoveProgress:"&swipeElementMove",onMoveEnd:"&swipeElement"},link:function(c,d){function e(b,c,d,e){var f="",g=b,h=c,i=g-p,j=h-q,k=Math.abs(i),l=Math.abs(j),m=j>0?"d":0>j?"u":"",n=i>0?"r":0>i?"l":"";(0!=l||0!=k)&&(f=l>k?m:n);var o={startX:b,startY:c,initialElementBounds:r,triggerType:e,source:d,x:g,y:h,deltaX:i,deltaY:j,dir:f,vDir:m,hDir:n};return a.extend({$event:o},o)}function f(a,b,f,g){p=a,q=b,r=d[0].getBoundingClientRect(),c.$apply(function(){c.onMoveStart(e(a,b,f,g))})}function g(a){f(a.touches[0].pageX,a.touches[0].pageY,a,"touch"),d.bind("touchmove",j),d.bind("touchend",m),o=!0}function h(a){var c=a.pageX,d=a.pageY;f(c,d,a,"mouse"),b.bind("mousemove",k),b.bind("mouseup",n)}function i(a,b,d,f){c.$apply(function(){c.onMoveProgress(e(a,b,d,f))})}function j(a){o&&(o=!1,a.preventDefault()),i(a.changedTouches[0].pageX,a.changedTouches[0].pageY,a,"touch")}function k(a){i(a.pageX,a.pageY,a,"mouse")}function l(a,b,d,f){c.$apply(function(){c.onMoveEnd(e(a,b,d,f))})}function m(a){o=!1,d.unbind("touchmove",j),d.unbind("touchend",m),l(a.changedTouches[0].pageX,a.changedTouches[0].pageY,a,"touch")}function n(a){b.unbind("mousemove",k),b.unbind("mouseup",n),l(a.pageX,a.pageY,a,"mouse")}d.bind("touchstart",g),d.bind("mousedown",h);var o=!1,p=null,q=null,r=null}}}var c=a.module("angular-swipe-element",[]);c.directive("swipeElement",b),b.$inject=["$document"]}(angular);