-
Notifications
You must be signed in to change notification settings - Fork 36
/
ng-croppie.min.js
1 lines (1 loc) · 2.46 KB
/
ng-croppie.min.js
1
!function(){"use strict";angular.module("ngCroppie",[]).directive("ngCroppie",["$timeout",function(o){return{restrict:"AE",scope:{src:"=",rotation:"=",viewport:"=",boundry:"=",type:"@",zoom:"@",mousezoom:"@",zoomslider:"@",exif:"@",enforceBoundary:"@",orientation:"@",update:"=",ngModel:"=",mobile:"@"},link:function(o,e,n){void 0===o.viewport&&(o.viewport={w:null,h:null}),void 0===o.boundry&&(o.boundry={w:null,h:null}),"true"===o.mobile?(o.viewport.w=250,o.viewport.h=250,o.boundry.w=300,o.boundry.h=300):(o.viewport.w=void 0!==o.viewport.w?o.viewport.w:300,o.viewport.h=void 0!==o.viewport.h?o.viewport.h:300,o.boundry.w=void 0!==o.boundry.w?o.boundry.w:400,o.boundry.h=void 0!==o.boundry.h?o.boundry.h:400),o.viewport.w>o.boundry.w&&(o.viewport.w=o.boundry.w),o.viewport.h>o.boundry.h&&(o.viewport.h=o.boundry.h);var t="true"===o.zoom||void 0===o.zoom,r="true"===o.mousezoom||void 0===o.mousezoom,i="true"===o.zoomslider||void 0===o.zoomslider,u={viewport:{width:o.viewport.w,height:o.viewport.h,type:o.type||"square"},boundary:{width:o.boundry.w,height:o.boundry.h},enableZoom:t,mouseWheelZoom:r,showZoomer:i,enableExif:o.exif,enforceBoundary:o.enforceBoundary,enableOrientation:o.orientation};void 0!==o.update&&(u.update=o.update);var a,d=new Croppie(e[0],u),l=angular.element(e[0])[0];angular.element(e[0].getElementsByClassName("cr-boundary"))[0].getBoundingClientRect();l.addEventListener("mousedown",function(){a=window.setInterval(function(){d.result("canvas").then(function(e){o.$apply(function(){o.ngModel=e})})},100)},!1),r&&(l.addEventListener("mousewheel",function(e){e.preventDefault(),d.result("canvas").then(function(e){o.$apply(function(){o.ngModel=e})})},!1),l.addEventListener("DOMMouseScroll",function(e){e.preventDefault(),d.result("canvas").then(function(e){o.$apply(function(){o.ngModel=e})})},!1)),l.addEventListener("mouseup",function(){clearInterval(a)},!1),l.addEventListener("mouseleave",function(){clearInterval(a)},!1),l.addEventListener("mouseout",function(){clearInterval(a)},!1),o.$on("$destroy",function(o){clearInterval(a)}),o.$watch("rotation",function(e,n){if("false"===o.orientation||void 0===o.orientation)throw"ngCroppie: Cannot rotate without 'orientation' option";d.rotate(e-n),d.result("canvas").then(function(e){o.$apply(function(){o.ngModel=e})})}),o.$watch("src",function(e,n){if(void 0===o.src)throw"ngCroppie: Image source undefined!";d.bind(o.src),window.setInterval(function(){d.result("canvas").then(function(e){o.$apply(function(){o.ngModel=e})})},0)})}}}])}();