<NME> we-cropper.min.js
<BEF> /**
 * we-cropper v1.3.1
 * (c) 2019 dlhandsome
 * @license MIT
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.WeCropper=e()}(this,function(){"use strict";var t=void 0,e=["touchstarted","touchmoved","touchended"];function r(n){for(var o=[],t=arguments.length-1;0<t--;)o[t]=arguments[t+1];e.forEach(function(t,e){void 0!==o[e]&&(n[t]=o[e])})}function n(){return t||(t=wx.getSystemInfoSync()),t}var o={},a={id:{default:"cropper",get:function(){return o.id},set:function(t){"string"!=typeof t&&console.error("id\uff1a"+t+" is invalid"),o.id=t}},width:{default:750,get:function(){return o.width},set:function(t){"number"!=typeof t&&console.error("width\uff1a"+t+" is invalid"),o.width=t}},height:{default:750,get:function(){return o.height},set:function(t){"number"!=typeof t&&console.error("height\uff1a"+t+" is invalid"),o.height=t}},pixelRatio:{default:n().pixelRatio,get:function(){return o.pixelRatio},set:function(t){"number"!=typeof t&&console.error("pixelRatio\uff1a"+t+" is invalid"),o.pixelRatio=t}},scale:{default:2.5,get:function(){return o.scale},set:function(t){"number"!=typeof t&&console.error("scale\uff1a"+t+" is invalid"),o.scale=t}},zoom:{default:5,get:function(){return o.zoom},set:function(t){"number"!=typeof t?console.error("zoom\uff1a"+t+" is invalid"):(t<0||10<t)&&console.error("zoom should be ranged in 0 ~ 10"),o.zoom=t}},src:{default:"",get:function(){return o.src},set:function(t){"string"!=typeof t&&console.error("src\uff1a"+t+" is invalid"),o.src=t}},cut:{default:{},get:function(){return o.cut},set:function(t){"object"!=typeof t&&console.error("cut\uff1a"+t+" is invalid"),o.cut=t}},boundStyle:{default:{},get:function(){return o.boundStyle},set:function(t){"object"!=typeof t&&console.error("boundStyle\uff1a"+t+" is invalid"),o.boundStyle=t}},onReady:{default:null,get:function(){return o.ready},set:function(t){o.ready=t}},onBeforeImageLoad:{default:null,get:function(){return o.beforeImageLoad},set:function(t){o.beforeImageLoad=t}},onImageLoad:{default:null,get:function(){return o.imageLoad},set:function(t){o.imageLoad=t}},onBeforeDraw:{default:null,get:function(){return o.beforeDraw},set:function(t){o.beforeDraw=t}}},i=n().windowWidth;var f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t,e){return t(e={exports:{}},e.exports),e.exports}var u=c(function(t,e){e.isStr=function(t){return"string"==typeof t},e.isNum=function(t){return"number"==typeof t},e.isArr=Array.isArray,e.isUndef=function(t){return void 0===t},e.isTrue=function(t){return!0===t},e.isFalse=function(t){return!1===t},e.isFunc=function(t){return"function"==typeof t},e.isObj=e.isObject=function(t){return null!==t&&"object"==typeof t};var n=Object.prototype.toString;e.isPlainObject=function(t){return"[object Object]"===n.call(t)};var o=Object.prototype.hasOwnProperty;e.hasOwn=function(t,e){return o.call(t,e)},e.noop=function(t,e,n){},e.isValidArrayIndex=function(t){var e=parseFloat(String(t));return 0<=e&&Math.floor(e)===e&&isFinite(t)}}),l=u.isFunc,g=u.isPlainObject,s=["ready","beforeImageLoad","beforeDraw","imageLoad"];function d(o){return function(t){return void 0===t&&(t={}),new Promise(function(e,n){t.success=function(t){e(t)},t.fail=function(t){n(t)},o(t)})}}function p(e,n){return void 0===n&&(n=!1),new Promise(function(t){e.draw(n,t)})}var v=d(wx.getImageInfo),y=d(wx.canvasToTempFilePath),h=c(function(u,h){!function(t){var e=h,n=u&&u.exports==e&&u,o="object"==typeof f&&f;o.global!==o&&o.window!==o||(t=o);var r=function(t){this.message=t};(r.prototype=new Error).name="InvalidCharacterError";var s=function(t){throw new r(t)},d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,a={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&s("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,o,r,a=t.length%3,i="",c=-1,u=t.length-a;++c<u;)e=t.charCodeAt(c)<<16,n=t.charCodeAt(++c)<<8,o=t.charCodeAt(++c),i+=d.charAt((r=e+n+o)>>18&63)+d.charAt(r>>12&63)+d.charAt(r>>6&63)+d.charAt(63&r);return 2==a?(e=t.charCodeAt(c)<<8,n=t.charCodeAt(++c),i+=d.charAt((r=e+n)>>10)+d.charAt(r>>4&63)+d.charAt(r<<2&63)+"="):1==a&&(r=t.charCodeAt(c),i+=d.charAt(r>>2)+d.charAt(r<<4&63)+"=="),i},decode:function(t){var e=(t=String(t).replace(c,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&s("Invalid character: the string to be decoded is not correctly encoded.");for(var n,o,r=0,a="",i=-1;++i<e;)o=d.indexOf(t.charAt(i)),n=r%4?64*n+o:o,r++%4&&(a+=String.fromCharCode(255&n>>(-2*r&6)));return a},version:"0.1.0"};if(e&&!e.nodeType)if(n)n.exports=a;else for(var i in a)a.hasOwnProperty(i)&&(e[i]=a[i]);else t.base64=a}(f)});function x(t){var e="";if("string"==typeof t)e=t;else for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return h.encode(e)}function m(t,e,n,o,r,a,i){var c,u,s,d,h,f;void 0===i&&(i=function(){}),void 0===a&&(a="png"),a="image/"+a.toLowerCase().replace(/jpg/i,"jpeg").match(/png|jpeg|bmp|gif/)[0],/bmp/.test(a)?(c=t,u=e,s=n,d=o,h=r,f=function(t){var e=function(t){var e=t.width,n=t.height,o=e*n*3,r=o+54,a=[66,77,255&r,r>>8&255,r>>16&255,r>>24&255,0,0,0,0,54,0,0,0],i=[40,0,0,0,255&e,e>>8&255,e>>16&255,e>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,1,0,24,0,0,0,0,0,255&o,o>>8&255,o>>16&255,o>>24&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=(4-3*e%4)%4,u=t.data,s="",d=e<<2,h=n,f=String.fromCharCode;do{for(var l=d*(h-1),g="",p=0;p<e;p++){var v=p<<2;g+=f(u[l+v+2])+f(u[l+v+1])+f(u[l+v])}for(var y=0;y<c;y++)g+=String.fromCharCode(0);s+=g}while(--h);return x(a.concat(i))+x(s)}(t);l(i)&&i("data:"+("image/"+a)+";base64,"+e)},wx.canvasGetImageData({canvasId:c,x:u,y:s,width:d,height:h,success:function(t){f(t)},fail:function(t){f(null),console.error("canvasGetImageData error: "+t)}})):console.error("\u6682\u4e0d\u652f\u6301\u751f\u6210'"+a+"'\u7c7b\u578b\u7684base64\u56fe\u7247")}var b=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=function(){}),m(t.canvasId,t.x,t.y,t.width,t.height,"bmp",e)};var w={touchStart:function(t){var e=t.touches,n=e[0],o=e[1];this.src&&(r(this,!0,null,null),this.__oneTouchStart(n),2<=t.touches.length&&this.__twoTouchStart(n,o))},touchMove:function(t){var e=t.touches,n=e[0],o=e[1];this.src&&(r(this,null,!0),1===t.touches.length&&this.__oneTouchMove(n),2<=t.touches.length&&this.__twoTouchMove(n,o))},touchEnd:function(t){this.src&&(r(this,!1,!1,!0),this.__xtouchEnd())}};var C=function(t){var e,n,o=this,r={};return e=o,n=a,Object.defineProperties(e,n),Object.keys(a).forEach(function(t){r[t]=a[t].default}),Object.assign(o,r,t),o.prepare(),o.attachPage(),o.createCtx(),o.observer(),o.cutt(),o.methods(),o.init(),o.update(),o};return C.prototype.init=function(){var t=this,e=t.src;return t.version="1.3.1","function"==typeof t.onReady&&t.onReady(t.ctx,t),e?t.pushOrign(e):t.updateCanvas(),r(t,!1,!1,!1),t.oldScale=1,t.newScale=1,t},Object.assign(C.prototype,w),C.prototype.prepare=function(){var n=this;n.attachPage=function(){var t=getCurrentPages(),e=t[t.length-1];Object.defineProperty(e,"wecropper",{get:function(){return console.warn("Instance will not be automatically bound to the page after v1.4.0\n\nPlease use a custom instance name instead\n\nExample: \nthis.mycropper = new WeCropper(options)\n\n// ...\nthis.mycropper.getCropperImage()"),n}})},n.createCtx=function(){var t=n.id,e=n.targetId;t?(n.ctx=wx.createCanvasContext(t),n.targetCtx=wx.createCanvasContext(e)):console.error("constructor: create canvas context failed, 'id' must be valuable")},n.deviceRadio=i/750},C.prototype.observer=function(){var o=this;o.on=function(t,e){var n;return-1<s.indexOf(t)?l(e)&&("ready"===t?e(o):o["on"+(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=e):console.error("event: "+t+" is invalid"),o}},C.prototype.methods=function(){var a=this,t=a.width,e=a.height,n=a.id,i=a.targetId,c=a.pixelRatio,o=a.cut,u=o.x;void 0===u&&(u=0);var s=o.y;void 0===s&&(s=0);var d=o.width;void 0===d&&(d=t);var h=o.height;void 0===h&&(h=e),a.updateCanvas=function(){return a.croperTarget&&a.ctx.drawImage(a.croperTarget,a.imgLeft,a.imgTop,a.scaleWidth,a.scaleHeight),l(a.onBeforeDraw)&&a.onBeforeDraw(a.ctx,a),a.setBoundStyle(a.boundStyle),p(a.ctx)},a.pushOrign=function(t){return a.src=t,l(a.onBeforeImageLoad)&&a.onBeforeImageLoad(a.ctx,a),v({src:t}).then(function(t){var e=t.width/t.height,n=d/h;return a.croperTarget=t.path,e<n?(a.rectX=u,a.baseWidth=d,a.baseHeight=d/e,a.rectY=s-Math.abs((h-a.baseHeight)/2)):(a.rectY=s,a.baseWidth=h*e,a.baseHeight=h,a.rectX=u-Math.abs((d-a.baseWidth)/2)),a.imgLeft=a.rectX,a.imgTop=a.rectY,a.scaleWidth=a.baseWidth,a.scaleHeight=a.baseHeight,a.update(),a.updateCanvas()}).then(function(){l(a.onImageLoad)&&a.onImageLoad(a.ctx,a)})},a.getCropperBase64=function(t){void 0===t&&(t=function(){}),b({canvasId:n,x:u,y:s,width:d,height:h},t)},a.getCropperImage=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],o=t[t.length-1];a.targetCtx.drawImage(a.croperTarget,a.imgLeft*c,a.imgTop*c,a.scaleWidth*c,a.scaleHeight*c);var r={canvasId:i,x:u*c,y:s*c,width:d*c,height:h*c};return p(a.targetCtx).then(function(){return g(n)&&(r=Object.assign({},r,n)),y(r)}).then(function(t){var e=t.tempFilePath;return l(o)&&o.call(a,e),e}).catch(function(){l(o)&&o.call(a,null)})}},C.prototype.cutt=function(){var a=this,i=a.width,c=a.height,t=a.cut,u=t.x;void 0===u&&(u=0);var s=t.y;void 0===s&&(s=0);var d=t.width;void 0===d&&(d=i);var h=t.height;void 0===h&&(h=c),a.outsideBound=function(t,e){a.imgLeft=u<=t?u:a.scaleWidth+t-u<=d?u+d-a.scaleWidth:t,a.imgTop=s<=e?s:a.scaleHeight+e-s<=h?s+h-a.scaleHeight:e},a.setBoundStyle=function(t){void 0===t&&(t={});var e=t.color;void 0===e&&(e="#04b00f");var n=t.mask;void 0===n&&(n="rgba(0, 0, 0, 0.3)");var o=t.lineWidth;void 0===o&&(o=1);var r=[{start:{x:u-o,y:s+10-o},step1:{x:u-o,y:s-o},step2:{x:u+10-o,y:s-o}},{start:{x:u-o,y:s+h-10+o},step1:{x:u-o,y:s+h+o},step2:{x:u+10-o,y:s+h+o}},{start:{x:u+d-10+o,y:s-o},step1:{x:u+d+o,y:s-o},step2:{x:u+d+o,y:s+10-o}},{start:{x:u+d+o,y:s+h-10+o},step1:{x:u+d+o,y:s+h+o},step2:{x:u+d-10+o,y:s+h+o}}];a.ctx.beginPath(),a.ctx.setFillStyle(n),a.ctx.fillRect(0,0,u,c),a.ctx.fillRect(u,0,d,s),a.ctx.fillRect(u,s+h,d,c-s-h),a.ctx.fillRect(u+d,0,i-u-d,c),a.ctx.fill(),r.forEach(function(t){a.ctx.beginPath(),a.ctx.setStrokeStyle(e),a.ctx.setLineWidth(o),a.ctx.moveTo(t.start.x,t.start.y),a.ctx.lineTo(t.step1.x,t.step1.y),a.ctx.lineTo(t.step2.x,t.step2.y),a.ctx.stroke()})}},C.prototype.update=function(){var p=this;p.src&&(p.__oneTouchStart=function(t){p.touchX0=Math.round(t.x),p.touchY0=Math.round(t.y)},p.__oneTouchMove=function(t){var e,n;if(p.touchended)return p.updateCanvas();e=Math.round(t.x-p.touchX0),n=Math.round(t.y-p.touchY0);var o=Math.round(p.rectX+e),r=Math.round(p.rectY+n);p.outsideBound(o,r),p.updateCanvas()},p.__twoTouchStart=function(t,e){var n,o,r;p.touchX1=Math.round(p.rectX+p.scaleWidth/2),p.touchY1=Math.round(p.rectY+p.scaleHeight/2),n=Math.round(e.x-t.x),o=Math.round(e.y-t.y),r=Math.round(Math.sqrt(n*n+o*o)),p.oldDistance=r},p.__twoTouchMove=function(t,e){var n,o,r,a,i,c,u,s=p.oldScale,d=p.oldDistance,h=p.scale,f=p.zoom;p.newScale=(n=s,o=d,r=f,a=t,i=e,c=Math.round(i.x-a.x),u=Math.round(i.y-a.y),n+.001*r*(Math.round(Math.sqrt(c*c+u*u))-o)),p.newScale<=1&&(p.newScale=1),p.newScale>=h&&(p.newScale=h),p.scaleWidth=Math.round(p.newScale*p.baseWidth),p.scaleHeight=Math.round(p.newScale*p.baseHeight);var l=Math.round(p.touchX1-p.scaleWidth/2),g=Math.round(p.touchY1-p.scaleHeight/2);p.outsideBound(l,g),p.updateCanvas()},p.__xtouchEnd=function(){p.oldScale=p.newScale,p.rectX=p.imgLeft,p.rectY=p.imgTop})},C});

<MSG> release: 1.3.2

<DFF> @@ -1,6 +1,6 @@
 /**
- * we-cropper v1.3.1
+ * we-cropper v1.3.2
  * (c) 2019 dlhandsome
  * @license MIT
  */
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.WeCropper=e()}(this,function(){"use strict";var t=void 0,e=["touchstarted","touchmoved","touchended"];function r(n){for(var o=[],t=arguments.length-1;0<t--;)o[t]=arguments[t+1];e.forEach(function(t,e){void 0!==o[e]&&(n[t]=o[e])})}function n(){return t||(t=wx.getSystemInfoSync()),t}var o={},a={id:{default:"cropper",get:function(){return o.id},set:function(t){"string"!=typeof t&&console.error("id\uff1a"+t+" is invalid"),o.id=t}},width:{default:750,get:function(){return o.width},set:function(t){"number"!=typeof t&&console.error("width\uff1a"+t+" is invalid"),o.width=t}},height:{default:750,get:function(){return o.height},set:function(t){"number"!=typeof t&&console.error("height\uff1a"+t+" is invalid"),o.height=t}},pixelRatio:{default:n().pixelRatio,get:function(){return o.pixelRatio},set:function(t){"number"!=typeof t&&console.error("pixelRatio\uff1a"+t+" is invalid"),o.pixelRatio=t}},scale:{default:2.5,get:function(){return o.scale},set:function(t){"number"!=typeof t&&console.error("scale\uff1a"+t+" is invalid"),o.scale=t}},zoom:{default:5,get:function(){return o.zoom},set:function(t){"number"!=typeof t?console.error("zoom\uff1a"+t+" is invalid"):(t<0||10<t)&&console.error("zoom should be ranged in 0 ~ 10"),o.zoom=t}},src:{default:"",get:function(){return o.src},set:function(t){"string"!=typeof t&&console.error("src\uff1a"+t+" is invalid"),o.src=t}},cut:{default:{},get:function(){return o.cut},set:function(t){"object"!=typeof t&&console.error("cut\uff1a"+t+" is invalid"),o.cut=t}},boundStyle:{default:{},get:function(){return o.boundStyle},set:function(t){"object"!=typeof t&&console.error("boundStyle\uff1a"+t+" is invalid"),o.boundStyle=t}},onReady:{default:null,get:function(){return o.ready},set:function(t){o.ready=t}},onBeforeImageLoad:{default:null,get:function(){return o.beforeImageLoad},set:function(t){o.beforeImageLoad=t}},onImageLoad:{default:null,get:function(){return o.imageLoad},set:function(t){o.imageLoad=t}},onBeforeDraw:{default:null,get:function(){return o.beforeDraw},set:function(t){o.beforeDraw=t}}},i=n().windowWidth;var f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t,e){return t(e={exports:{}},e.exports),e.exports}var u=c(function(t,e){e.isStr=function(t){return"string"==typeof t},e.isNum=function(t){return"number"==typeof t},e.isArr=Array.isArray,e.isUndef=function(t){return void 0===t},e.isTrue=function(t){return!0===t},e.isFalse=function(t){return!1===t},e.isFunc=function(t){return"function"==typeof t},e.isObj=e.isObject=function(t){return null!==t&&"object"==typeof t};var n=Object.prototype.toString;e.isPlainObject=function(t){return"[object Object]"===n.call(t)};var o=Object.prototype.hasOwnProperty;e.hasOwn=function(t,e){return o.call(t,e)},e.noop=function(t,e,n){},e.isValidArrayIndex=function(t){var e=parseFloat(String(t));return 0<=e&&Math.floor(e)===e&&isFinite(t)}}),l=u.isFunc,g=u.isPlainObject,s=["ready","beforeImageLoad","beforeDraw","imageLoad"];function d(o){return function(t){return void 0===t&&(t={}),new Promise(function(e,n){t.success=function(t){e(t)},t.fail=function(t){n(t)},o(t)})}}function p(e,n){return void 0===n&&(n=!1),new Promise(function(t){e.draw(n,t)})}var v=d(wx.getImageInfo),y=d(wx.canvasToTempFilePath),h=c(function(u,h){!function(t){var e=h,n=u&&u.exports==e&&u,o="object"==typeof f&&f;o.global!==o&&o.window!==o||(t=o);var r=function(t){this.message=t};(r.prototype=new Error).name="InvalidCharacterError";var s=function(t){throw new r(t)},d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,a={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&s("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,o,r,a=t.length%3,i="",c=-1,u=t.length-a;++c<u;)e=t.charCodeAt(c)<<16,n=t.charCodeAt(++c)<<8,o=t.charCodeAt(++c),i+=d.charAt((r=e+n+o)>>18&63)+d.charAt(r>>12&63)+d.charAt(r>>6&63)+d.charAt(63&r);return 2==a?(e=t.charCodeAt(c)<<8,n=t.charCodeAt(++c),i+=d.charAt((r=e+n)>>10)+d.charAt(r>>4&63)+d.charAt(r<<2&63)+"="):1==a&&(r=t.charCodeAt(c),i+=d.charAt(r>>2)+d.charAt(r<<4&63)+"=="),i},decode:function(t){var e=(t=String(t).replace(c,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&s("Invalid character: the string to be decoded is not correctly encoded.");for(var n,o,r=0,a="",i=-1;++i<e;)o=d.indexOf(t.charAt(i)),n=r%4?64*n+o:o,r++%4&&(a+=String.fromCharCode(255&n>>(-2*r&6)));return a},version:"0.1.0"};if(e&&!e.nodeType)if(n)n.exports=a;else for(var i in a)a.hasOwnProperty(i)&&(e[i]=a[i]);else t.base64=a}(f)});function x(t){var e="";if("string"==typeof t)e=t;else for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return h.encode(e)}function m(t,e,n,o,r,a,i){var c,u,s,d,h,f;void 0===i&&(i=function(){}),void 0===a&&(a="png"),a="image/"+a.toLowerCase().replace(/jpg/i,"jpeg").match(/png|jpeg|bmp|gif/)[0],/bmp/.test(a)?(c=t,u=e,s=n,d=o,h=r,f=function(t){var e=function(t){var e=t.width,n=t.height,o=e*n*3,r=o+54,a=[66,77,255&r,r>>8&255,r>>16&255,r>>24&255,0,0,0,0,54,0,0,0],i=[40,0,0,0,255&e,e>>8&255,e>>16&255,e>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,1,0,24,0,0,0,0,0,255&o,o>>8&255,o>>16&255,o>>24&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=(4-3*e%4)%4,u=t.data,s="",d=e<<2,h=n,f=String.fromCharCode;do{for(var l=d*(h-1),g="",p=0;p<e;p++){var v=p<<2;g+=f(u[l+v+2])+f(u[l+v+1])+f(u[l+v])}for(var y=0;y<c;y++)g+=String.fromCharCode(0);s+=g}while(--h);return x(a.concat(i))+x(s)}(t);l(i)&&i("data:"+("image/"+a)+";base64,"+e)},wx.canvasGetImageData({canvasId:c,x:u,y:s,width:d,height:h,success:function(t){f(t)},fail:function(t){f(null),console.error("canvasGetImageData error: "+t)}})):console.error("\u6682\u4e0d\u652f\u6301\u751f\u6210'"+a+"'\u7c7b\u578b\u7684base64\u56fe\u7247")}var b=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=function(){}),m(t.canvasId,t.x,t.y,t.width,t.height,"bmp",e)};var w={touchStart:function(t){var e=t.touches,n=e[0],o=e[1];this.src&&(r(this,!0,null,null),this.__oneTouchStart(n),2<=t.touches.length&&this.__twoTouchStart(n,o))},touchMove:function(t){var e=t.touches,n=e[0],o=e[1];this.src&&(r(this,null,!0),1===t.touches.length&&this.__oneTouchMove(n),2<=t.touches.length&&this.__twoTouchMove(n,o))},touchEnd:function(t){this.src&&(r(this,!1,!1,!0),this.__xtouchEnd())}};var C=function(t){var e,n,o=this,r={};return e=o,n=a,Object.defineProperties(e,n),Object.keys(a).forEach(function(t){r[t]=a[t].default}),Object.assign(o,r,t),o.prepare(),o.attachPage(),o.createCtx(),o.observer(),o.cutt(),o.methods(),o.init(),o.update(),o};return C.prototype.init=function(){var t=this,e=t.src;return t.version="1.3.1","function"==typeof t.onReady&&t.onReady(t.ctx,t),e?t.pushOrign(e):t.updateCanvas(),r(t,!1,!1,!1),t.oldScale=1,t.newScale=1,t},Object.assign(C.prototype,w),C.prototype.prepare=function(){var n=this;n.attachPage=function(){var t=getCurrentPages(),e=t[t.length-1];Object.defineProperty(e,"wecropper",{get:function(){return console.warn("Instance will not be automatically bound to the page after v1.4.0\n\nPlease use a custom instance name instead\n\nExample: \nthis.mycropper = new WeCropper(options)\n\n// ...\nthis.mycropper.getCropperImage()"),n}})},n.createCtx=function(){var t=n.id,e=n.targetId;t?(n.ctx=wx.createCanvasContext(t),n.targetCtx=wx.createCanvasContext(e)):console.error("constructor: create canvas context failed, 'id' must be valuable")},n.deviceRadio=i/750},C.prototype.observer=function(){var o=this;o.on=function(t,e){var n;return-1<s.indexOf(t)?l(e)&&("ready"===t?e(o):o["on"+(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=e):console.error("event: "+t+" is invalid"),o}},C.prototype.methods=function(){var a=this,t=a.width,e=a.height,n=a.id,i=a.targetId,c=a.pixelRatio,o=a.cut,u=o.x;void 0===u&&(u=0);var s=o.y;void 0===s&&(s=0);var d=o.width;void 0===d&&(d=t);var h=o.height;void 0===h&&(h=e),a.updateCanvas=function(){return a.croperTarget&&a.ctx.drawImage(a.croperTarget,a.imgLeft,a.imgTop,a.scaleWidth,a.scaleHeight),l(a.onBeforeDraw)&&a.onBeforeDraw(a.ctx,a),a.setBoundStyle(a.boundStyle),p(a.ctx)},a.pushOrign=function(t){return a.src=t,l(a.onBeforeImageLoad)&&a.onBeforeImageLoad(a.ctx,a),v({src:t}).then(function(t){var e=t.width/t.height,n=d/h;return a.croperTarget=t.path,e<n?(a.rectX=u,a.baseWidth=d,a.baseHeight=d/e,a.rectY=s-Math.abs((h-a.baseHeight)/2)):(a.rectY=s,a.baseWidth=h*e,a.baseHeight=h,a.rectX=u-Math.abs((d-a.baseWidth)/2)),a.imgLeft=a.rectX,a.imgTop=a.rectY,a.scaleWidth=a.baseWidth,a.scaleHeight=a.baseHeight,a.update(),a.updateCanvas()}).then(function(){l(a.onImageLoad)&&a.onImageLoad(a.ctx,a)})},a.getCropperBase64=function(t){void 0===t&&(t=function(){}),b({canvasId:n,x:u,y:s,width:d,height:h},t)},a.getCropperImage=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],o=t[t.length-1];a.targetCtx.drawImage(a.croperTarget,a.imgLeft*c,a.imgTop*c,a.scaleWidth*c,a.scaleHeight*c);var r={canvasId:i,x:u*c,y:s*c,width:d*c,height:h*c};return p(a.targetCtx).then(function(){return g(n)&&(r=Object.assign({},r,n)),y(r)}).then(function(t){var e=t.tempFilePath;return l(o)&&o.call(a,e),e}).catch(function(){l(o)&&o.call(a,null)})}},C.prototype.cutt=function(){var a=this,i=a.width,c=a.height,t=a.cut,u=t.x;void 0===u&&(u=0);var s=t.y;void 0===s&&(s=0);var d=t.width;void 0===d&&(d=i);var h=t.height;void 0===h&&(h=c),a.outsideBound=function(t,e){a.imgLeft=u<=t?u:a.scaleWidth+t-u<=d?u+d-a.scaleWidth:t,a.imgTop=s<=e?s:a.scaleHeight+e-s<=h?s+h-a.scaleHeight:e},a.setBoundStyle=function(t){void 0===t&&(t={});var e=t.color;void 0===e&&(e="#04b00f");var n=t.mask;void 0===n&&(n="rgba(0, 0, 0, 0.3)");var o=t.lineWidth;void 0===o&&(o=1);var r=[{start:{x:u-o,y:s+10-o},step1:{x:u-o,y:s-o},step2:{x:u+10-o,y:s-o}},{start:{x:u-o,y:s+h-10+o},step1:{x:u-o,y:s+h+o},step2:{x:u+10-o,y:s+h+o}},{start:{x:u+d-10+o,y:s-o},step1:{x:u+d+o,y:s-o},step2:{x:u+d+o,y:s+10-o}},{start:{x:u+d+o,y:s+h-10+o},step1:{x:u+d+o,y:s+h+o},step2:{x:u+d-10+o,y:s+h+o}}];a.ctx.beginPath(),a.ctx.setFillStyle(n),a.ctx.fillRect(0,0,u,c),a.ctx.fillRect(u,0,d,s),a.ctx.fillRect(u,s+h,d,c-s-h),a.ctx.fillRect(u+d,0,i-u-d,c),a.ctx.fill(),r.forEach(function(t){a.ctx.beginPath(),a.ctx.setStrokeStyle(e),a.ctx.setLineWidth(o),a.ctx.moveTo(t.start.x,t.start.y),a.ctx.lineTo(t.step1.x,t.step1.y),a.ctx.lineTo(t.step2.x,t.step2.y),a.ctx.stroke()})}},C.prototype.update=function(){var p=this;p.src&&(p.__oneTouchStart=function(t){p.touchX0=Math.round(t.x),p.touchY0=Math.round(t.y)},p.__oneTouchMove=function(t){var e,n;if(p.touchended)return p.updateCanvas();e=Math.round(t.x-p.touchX0),n=Math.round(t.y-p.touchY0);var o=Math.round(p.rectX+e),r=Math.round(p.rectY+n);p.outsideBound(o,r),p.updateCanvas()},p.__twoTouchStart=function(t,e){var n,o,r;p.touchX1=Math.round(p.rectX+p.scaleWidth/2),p.touchY1=Math.round(p.rectY+p.scaleHeight/2),n=Math.round(e.x-t.x),o=Math.round(e.y-t.y),r=Math.round(Math.sqrt(n*n+o*o)),p.oldDistance=r},p.__twoTouchMove=function(t,e){var n,o,r,a,i,c,u,s=p.oldScale,d=p.oldDistance,h=p.scale,f=p.zoom;p.newScale=(n=s,o=d,r=f,a=t,i=e,c=Math.round(i.x-a.x),u=Math.round(i.y-a.y),n+.001*r*(Math.round(Math.sqrt(c*c+u*u))-o)),p.newScale<=1&&(p.newScale=1),p.newScale>=h&&(p.newScale=h),p.scaleWidth=Math.round(p.newScale*p.baseWidth),p.scaleHeight=Math.round(p.newScale*p.baseHeight);var l=Math.round(p.touchX1-p.scaleWidth/2),g=Math.round(p.touchY1-p.scaleHeight/2);p.outsideBound(l,g),p.updateCanvas()},p.__xtouchEnd=function(){p.oldScale=p.newScale,p.rectX=p.imgLeft,p.rectY=p.imgTop})},C});
\ No newline at end of file
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.WeCropper=e()}(this,function(){"use strict";var t=void 0,e=["touchstarted","touchmoved","touchended"];function r(n){for(var o=[],t=arguments.length-1;0<t--;)o[t]=arguments[t+1];e.forEach(function(t,e){void 0!==o[e]&&(n[t]=o[e])})}function n(){return t||(t=wx.getSystemInfoSync()),t}var o={},a={id:{default:"cropper",get:function(){return o.id},set:function(t){"string"!=typeof t&&console.error("id\uff1a"+t+" is invalid"),o.id=t}},width:{default:750,get:function(){return o.width},set:function(t){"number"!=typeof t&&console.error("width\uff1a"+t+" is invalid"),o.width=t}},height:{default:750,get:function(){return o.height},set:function(t){"number"!=typeof t&&console.error("height\uff1a"+t+" is invalid"),o.height=t}},pixelRatio:{default:n().pixelRatio,get:function(){return o.pixelRatio},set:function(t){"number"!=typeof t&&console.error("pixelRatio\uff1a"+t+" is invalid"),o.pixelRatio=t}},scale:{default:2.5,get:function(){return o.scale},set:function(t){"number"!=typeof t&&console.error("scale\uff1a"+t+" is invalid"),o.scale=t}},zoom:{default:5,get:function(){return o.zoom},set:function(t){"number"!=typeof t?console.error("zoom\uff1a"+t+" is invalid"):(t<0||10<t)&&console.error("zoom should be ranged in 0 ~ 10"),o.zoom=t}},src:{default:"",get:function(){return o.src},set:function(t){"string"!=typeof t&&console.error("src\uff1a"+t+" is invalid"),o.src=t}},cut:{default:{},get:function(){return o.cut},set:function(t){"object"!=typeof t&&console.error("cut\uff1a"+t+" is invalid"),o.cut=t}},boundStyle:{default:{},get:function(){return o.boundStyle},set:function(t){"object"!=typeof t&&console.error("boundStyle\uff1a"+t+" is invalid"),o.boundStyle=t}},onReady:{default:null,get:function(){return o.ready},set:function(t){o.ready=t}},onBeforeImageLoad:{default:null,get:function(){return o.beforeImageLoad},set:function(t){o.beforeImageLoad=t}},onImageLoad:{default:null,get:function(){return o.imageLoad},set:function(t){o.imageLoad=t}},onBeforeDraw:{default:null,get:function(){return o.beforeDraw},set:function(t){o.beforeDraw=t}}},i=n().windowWidth;var f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t,e){return t(e={exports:{}},e.exports),e.exports}var u=c(function(t,e){e.isStr=function(t){return"string"==typeof t},e.isNum=function(t){return"number"==typeof t},e.isArr=Array.isArray,e.isUndef=function(t){return void 0===t},e.isTrue=function(t){return!0===t},e.isFalse=function(t){return!1===t},e.isFunc=function(t){return"function"==typeof t},e.isObj=e.isObject=function(t){return null!==t&&"object"==typeof t};var n=Object.prototype.toString;e.isPlainObject=function(t){return"[object Object]"===n.call(t)};var o=Object.prototype.hasOwnProperty;e.hasOwn=function(t,e){return o.call(t,e)},e.noop=function(t,e,n){},e.isValidArrayIndex=function(t){var e=parseFloat(String(t));return 0<=e&&Math.floor(e)===e&&isFinite(t)}}),g=u.isFunc,p=u.isPlainObject,s=["ready","beforeImageLoad","beforeDraw","imageLoad"];function d(o){return function(t){return void 0===t&&(t={}),new Promise(function(e,n){t.success=function(t){e(t)},t.fail=function(t){n(t)},o(t)})}}var v=d(wx.getImageInfo),y=d(wx.canvasToTempFilePath),h=c(function(u,h){!function(t){var e=h,n=u&&u.exports==e&&u,o="object"==typeof f&&f;o.global!==o&&o.window!==o||(t=o);var r=function(t){this.message=t};(r.prototype=new Error).name="InvalidCharacterError";var s=function(t){throw new r(t)},d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,a={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&s("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,o,r,a=t.length%3,i="",c=-1,u=t.length-a;++c<u;)e=t.charCodeAt(c)<<16,n=t.charCodeAt(++c)<<8,o=t.charCodeAt(++c),i+=d.charAt((r=e+n+o)>>18&63)+d.charAt(r>>12&63)+d.charAt(r>>6&63)+d.charAt(63&r);return 2==a?(e=t.charCodeAt(c)<<8,n=t.charCodeAt(++c),i+=d.charAt((r=e+n)>>10)+d.charAt(r>>4&63)+d.charAt(r<<2&63)+"="):1==a&&(r=t.charCodeAt(c),i+=d.charAt(r>>2)+d.charAt(r<<4&63)+"=="),i},decode:function(t){var e=(t=String(t).replace(c,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9/]/.test(t))&&s("Invalid character: the string to be decoded is not correctly encoded.");for(var n,o,r=0,a="",i=-1;++i<e;)o=d.indexOf(t.charAt(i)),n=r%4?64*n+o:o,r++%4&&(a+=String.fromCharCode(255&n>>(-2*r&6)));return a},version:"0.1.0"};if(e&&!e.nodeType)if(n)n.exports=a;else for(var i in a)a.hasOwnProperty(i)&&(e[i]=a[i]);else t.base64=a}(f)});function x(t){var e="";if("string"==typeof t)e=t;else for(var n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return h.encode(e)}function l(t,e,n,o,r,a,i){var c,u,s,d,h,f;void 0===i&&(i=function(){}),void 0===a&&(a="png"),a="image/"+a.toLowerCase().replace(/jpg/i,"jpeg").match(/png|jpeg|bmp|gif/)[0],/bmp/.test(a)?(c=t,u=e,s=n,d=o,h=r,f=function(t){var e=function(t){var e=t.width,n=t.height,o=e*n*3,r=o+54,a=[66,77,255&r,r>>8&255,r>>16&255,r>>24&255,0,0,0,0,54,0,0,0],i=[40,0,0,0,255&e,e>>8&255,e>>16&255,e>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,1,0,24,0,0,0,0,0,255&o,o>>8&255,o>>16&255,o>>24&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c=(4-3*e%4)%4,u=t.data,s="",d=e<<2,h=n,f=String.fromCharCode;do{for(var l=d*(h-1),g="",p=0;p<e;p++){var v=p<<2;g+=f(u[l+v+2])+f(u[l+v+1])+f(u[l+v])}for(var y=0;y<c;y++)g+=String.fromCharCode(0);s+=g}while(--h);return x(a.concat(i))+x(s)}(t);g(i)&&i("data:"+("image/"+a)+";base64,"+e)},wx.canvasGetImageData({canvasId:c,x:u,y:s,width:d,height:h,success:function(t){f(t)},fail:function(t){f(null),console.error("canvasGetImageData error: "+t)}})):console.error("\u6682\u4e0d\u652f\u6301\u751f\u6210'"+a+"'\u7c7b\u578b\u7684base64\u56fe\u7247")}var m=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=function(){}),l(t.canvasId,t.x,t.y,t.width,t.height,"bmp",e)};var b={touchStart:function(t){var e=t.touches,n=e[0],o=e[1];this.src&&(r(this,!0,null,null),this.__oneTouchStart(n),2<=t.touches.length&&this.__twoTouchStart(n,o))},touchMove:function(t){var e=t.touches,n=e[0],o=e[1];this.src&&(r(this,null,!0),1===t.touches.length&&this.__oneTouchMove(n),2<=t.touches.length&&this.__twoTouchMove(n,o))},touchEnd:function(t){this.src&&(r(this,!1,!1,!0),this.__xtouchEnd())}};var w=function(t){var e,n,o=this,r={};return e=o,n=a,Object.defineProperties(e,n),Object.keys(a).forEach(function(t){r[t]=a[t].default}),Object.assign(o,r,t),o.prepare(),o.attachPage(),o.createCtx(),o.observer(),o.cutt(),o.methods(),o.init(),o.update(),o};return w.prototype.init=function(){var t=this,e=t.src;return t.version="1.3.2","function"==typeof t.onReady&&t.onReady(t.ctx,t),e?t.pushOrign(e):t.updateCanvas(),r(t,!1,!1,!1),t.oldScale=1,t.newScale=1,t},Object.assign(w.prototype,b),w.prototype.prepare=function(){var n=this;n.attachPage=function(){var t=getCurrentPages(),e=t[t.length-1];Object.defineProperty(e,"wecropper",{get:function(){return console.warn("Instance will not be automatically bound to the page after v1.4.0\n\nPlease use a custom instance name instead\n\nExample: \nthis.mycropper = new WeCropper(options)\n\n// ...\nthis.mycropper.getCropperImage()"),n}})},n.createCtx=function(){var t=n.id,e=n.targetId;t?(n.ctx=wx.createCanvasContext(t),n.targetCtx=wx.createCanvasContext(e)):console.error("constructor: create canvas context failed, 'id' must be valuable")},n.deviceRadio=i/750},w.prototype.observer=function(){var o=this;o.on=function(t,e){var n;return-1<s.indexOf(t)?g(e)&&("ready"===t?e(o):o["on"+(n=t,n.charAt(0).toUpperCase()+n.slice(1))]=e):console.error("event: "+t+" is invalid"),o}},w.prototype.methods=function(){var c=this,t=c.width,e=c.height,n=c.id,u=c.targetId,s=c.pixelRatio,o=c.cut,d=o.x;void 0===d&&(d=0);var h=o.y;void 0===h&&(h=0);var f=o.width;void 0===f&&(f=t);var l=o.height;void 0===l&&(l=e),c.updateCanvas=function(t){return c.croperTarget&&c.ctx.drawImage(c.croperTarget,c.imgLeft,c.imgTop,c.scaleWidth,c.scaleHeight),g(c.onBeforeDraw)&&c.onBeforeDraw(c.ctx,c),c.setBoundStyle(c.boundStyle),c.ctx.draw(!1,t),c},c.pushOrign=function(t){return c.src=t,g(c.onBeforeImageLoad)&&c.onBeforeImageLoad(c.ctx,c),v({src:t}).then(function(t){var e=t.width/t.height,n=f/l;return c.croperTarget=t.path,e<n?(c.rectX=d,c.baseWidth=f,c.baseHeight=f/e,c.rectY=h-Math.abs((l-c.baseHeight)/2)):(c.rectY=h,c.baseWidth=l*e,c.baseHeight=l,c.rectX=d-Math.abs((f-c.baseWidth)/2)),c.imgLeft=c.rectX,c.imgTop=c.rectY,c.scaleWidth=c.baseWidth,c.scaleHeight=c.baseHeight,c.update(),new Promise(function(t){c.updateCanvas(t)})}).then(function(){g(c.onImageLoad)&&c.onImageLoad(c.ctx,c)})},c.getCropperBase64=function(t){void 0===t&&(t=function(){}),m({canvasId:n,x:d,y:h,width:f,height:l},t)},c.getCropperImage=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t[0],o=t[t.length-1];c.targetCtx.drawImage(c.croperTarget,c.imgLeft*s,c.imgTop*s,c.scaleWidth*s,c.scaleHeight*s);var r,a,i={canvasId:u,x:d*s,y:h*s,width:f*s,height:l*s};return(r=c.targetCtx,void 0===a&&(a=!1),new Promise(function(t){r.draw(a,t)})).then(function(){return p(n)&&(i=Object.assign({},i,n)),y(i)}).then(function(t){var e=t.tempFilePath;return g(o)&&o.call(c,e),e}).catch(function(){g(o)&&o.call(c,null)})}},w.prototype.cutt=function(){var a=this,i=a.width,c=a.height,t=a.cut,u=t.x;void 0===u&&(u=0);var s=t.y;void 0===s&&(s=0);var d=t.width;void 0===d&&(d=i);var h=t.height;void 0===h&&(h=c),a.outsideBound=function(t,e){a.imgLeft=u<=t?u:a.scaleWidth+t-u<=d?u+d-a.scaleWidth:t,a.imgTop=s<=e?s:a.scaleHeight+e-s<=h?s+h-a.scaleHeight:e},a.setBoundStyle=function(t){void 0===t&&(t={});var e=t.color;void 0===e&&(e="#04b00f");var n=t.mask;void 0===n&&(n="rgba(0, 0, 0, 0.3)");var o=t.lineWidth;void 0===o&&(o=1);var r=[{start:{x:u-o,y:s+10-o},step1:{x:u-o,y:s-o},step2:{x:u+10-o,y:s-o}},{start:{x:u-o,y:s+h-10+o},step1:{x:u-o,y:s+h+o},step2:{x:u+10-o,y:s+h+o}},{start:{x:u+d-10+o,y:s-o},step1:{x:u+d+o,y:s-o},step2:{x:u+d+o,y:s+10-o}},{start:{x:u+d+o,y:s+h-10+o},step1:{x:u+d+o,y:s+h+o},step2:{x:u+d-10+o,y:s+h+o}}];a.ctx.beginPath(),a.ctx.setFillStyle(n),a.ctx.fillRect(0,0,u,c),a.ctx.fillRect(u,0,d,s),a.ctx.fillRect(u,s+h,d,c-s-h),a.ctx.fillRect(u+d,0,i-u-d,c),a.ctx.fill(),r.forEach(function(t){a.ctx.beginPath(),a.ctx.setStrokeStyle(e),a.ctx.setLineWidth(o),a.ctx.moveTo(t.start.x,t.start.y),a.ctx.lineTo(t.step1.x,t.step1.y),a.ctx.lineTo(t.step2.x,t.step2.y),a.ctx.stroke()})}},w.prototype.update=function(){var p=this;p.src&&(p.__oneTouchStart=function(t){p.touchX0=Math.round(t.x),p.touchY0=Math.round(t.y)},p.__oneTouchMove=function(t){var e,n;if(p.touchended)return p.updateCanvas();e=Math.round(t.x-p.touchX0),n=Math.round(t.y-p.touchY0);var o=Math.round(p.rectX+e),r=Math.round(p.rectY+n);p.outsideBound(o,r),p.updateCanvas()},p.__twoTouchStart=function(t,e){var n,o,r;p.touchX1=Math.round(p.rectX+p.scaleWidth/2),p.touchY1=Math.round(p.rectY+p.scaleHeight/2),n=Math.round(e.x-t.x),o=Math.round(e.y-t.y),r=Math.round(Math.sqrt(n*n+o*o)),p.oldDistance=r},p.__twoTouchMove=function(t,e){var n,o,r,a,i,c,u,s=p.oldScale,d=p.oldDistance,h=p.scale,f=p.zoom;p.newScale=(n=s,o=d,r=f,a=t,i=e,c=Math.round(i.x-a.x),u=Math.round(i.y-a.y),n+.001*r*(Math.round(Math.sqrt(c*c+u*u))-o)),p.newScale<=1&&(p.newScale=1),p.newScale>=h&&(p.newScale=h),p.scaleWidth=Math.round(p.newScale*p.baseWidth),p.scaleHeight=Math.round(p.newScale*p.baseHeight);var l=Math.round(p.touchX1-p.scaleWidth/2),g=Math.round(p.touchY1-p.scaleHeight/2);p.outsideBound(l,g),p.updateCanvas()},p.__xtouchEnd=function(){p.oldScale=p.newScale,p.rectX=p.imgLeft,p.rectY=p.imgTop})},w});
\ No newline at end of file

release: 1.3.2