From: john@roojs.com Date: Wed, 16 Jan 2019 02:38:16 +0000 (+0800) Subject: FIX: bezier resize without width X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=2542b67d1a0768025056f2f330bfe50b64d1ad38 FIX: bezier resize without width --- diff --git a/Roo/bootstrap/BezierSignature.js b/Roo/bootstrap/BezierSignature.js index 379c181cc3..65bb2d26ba 100644 --- a/Roo/bootstrap/BezierSignature.js +++ b/Roo/bootstrap/BezierSignature.js @@ -174,8 +174,11 @@ Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component, { var canvas = this.canvasEl().dom; var ctx = this.canvasElCtx(); - var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height); + var img_data = false; + if(canvas.width > 0) { + var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height); + } // setting canvas width will clean img data canvas.width = 0; @@ -187,7 +190,9 @@ Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component, { canvas.width = this.el.dom.clientWidth - padding_left - padding_right; - ctx.putImageData(img_data, 0, 0); + if(img_data) { + ctx.putImageData(img_data, 0, 0); + } }, _handleMouseDown: function(e) diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 3fc684a5d2..c991ffff1c 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -41676,8 +41676,11 @@ Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component, { var canvas = this.canvasEl().dom; var ctx = this.canvasElCtx(); - var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height); + var img_data = false; + if(canvas.width > 0) { + var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height); + } // setting canvas width will clean img data canvas.width = 0; @@ -41689,7 +41692,9 @@ Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component, { canvas.width = this.el.dom.clientWidth - padding_left - padding_right; - ctx.putImageData(img_data, 0, 0); + if(img_data) { + ctx.putImageData(img_data, 0, 0); + } }, _handleMouseDown: function(e) diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index b8a92f657d..6a9ae0465c 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1736,8 +1736,8 @@ if(this.cls){A+=' '+this.cls;}var B=['lg','md','sm','xs'];for(var i=0;i0){var C=B.getImageData(0,0,A.width,A.height);}A.width=0;var D=window.getComputedStyle?getComputedStyle(this.el.dom,null):this.el.dom.currentStyle; +var E=parseInt(D.paddingLeft)||0;var F=parseInt(D.paddingRight)||0;A.width=this.el.dom.clientWidth-E-F;if(C){B.putImageData(C,0,0);}},_handleMouseDown:function(e){if(e.browserEvent.which===1){this.mouse_btn_down=true;this.strokeBegin(e);}},_handleMouseMove:function(e){if(this.mouse_btn_down){this.strokeMoveUpdate(e); }},_handleMouseUp:function(e){if(e.browserEvent.which===1&&this.mouse_btn_down){this.mouse_btn_down=false;this.strokeEnd(e);}},_handleTouchStart:function(e){e.preventDefault();if(e.browserEvent.targetTouches.length===1){this.strokeBegin(e);}},_handleTouchMove:function(e){e.preventDefault(); this.strokeMoveUpdate(e);},_handleTouchEnd:function(e){var A=e.target===this.canvasEl().dom;if(A){e.preventDefault();this.strokeEnd(e);}},reset:function(){this._lastPoints=[];this._lastVelocity=0;this._lastWidth=(this.min_width+this.max_width)/2;this.canvasElCtx().fillStyle=this.dot_color; },strokeMoveUpdate:function(e){this.strokeUpdate(e);if(this.throttle){this.throttle(this.strokeUpdate,this.throttle);}else{this.strokeUpdate(e);}},strokeBegin:function(e){var A={color:this.dot_color,points:[]};if(typeof this.onBegin==='function'){this.onBegin(e);