11/* 
2-  * vue-croppa v0.2.0  
2+  * vue-croppa v0.2.1  
33 * https://github.com/zhanziyang/vue-croppa 
44 *  
55 * Copyright (c) 2017 zhanziyang 
@@ -487,12 +487,44 @@ var component = { render: function render() {
487487    value : function  value ( val )  { 
488488      this . instance  =  val ; 
489489    } , 
490-     realWidth : 'init' , 
491-     realHeight : 'init' , 
492-     canvasColor : 'init' , 
493-     placeholder : 'init' , 
494-     placeholderColor : 'init' , 
495-     realPlaceholderFontSize : 'init' , 
490+     realWidth : function  realWidth ( )  { 
491+       if  ( ! this . img )  { 
492+         this . init ( ) ; 
493+       }  else  { 
494+         this . setSize ( ) ; 
495+         this . imgContentInit ( ) ; 
496+       } 
497+     } , 
498+     realHeight : function  realHeight ( )  { 
499+       if  ( ! this . img )  { 
500+         this . init ( ) ; 
501+       }  else  { 
502+         this . setSize ( ) ; 
503+         this . imgContentInit ( ) ; 
504+       } 
505+     } , 
506+     canvasColor : function  canvasColor ( )  { 
507+       if  ( ! this . img )  { 
508+         this . init ( ) ; 
509+       }  else  { 
510+         this . draw ( ) ; 
511+       } 
512+     } , 
513+     placeholder : function  placeholder ( )  { 
514+       if  ( ! this . img )  { 
515+         this . init ( ) ; 
516+       } 
517+     } , 
518+     placeholderColor : function  placeholderColor ( )  { 
519+       if  ( ! this . img )  { 
520+         this . init ( ) ; 
521+       } 
522+     } , 
523+     realPlaceholderFontSize : function  realPlaceholderFontSize ( )  { 
524+       if  ( ! this . img )  { 
525+         this . init ( ) ; 
526+       } 
527+     } , 
496528    preventWhiteSpace : function  preventWhiteSpace ( )  { 
497529      this . imgContentInit ( ) ; 
498530    } 
@@ -503,13 +535,8 @@ var component = { render: function render() {
503535      var  _this  =  this ; 
504536
505537      this . canvas  =  this . $refs . canvas ; 
506-       this . canvas . width  =  this . realWidth ; 
507-       this . canvas . height  =  this . realHeight ; 
508-       this . canvas . style . width  =  this . width  +  'px' ; 
509-       this . canvas . style . height  =  this . height  +  'px' ; 
510-       // this.$refs.wrapper.style.width = this.width + 'px' 
511-       // this.$refs.wrapper.style.height = this.height + 'px' 
512-       this . canvas . style . backgroundColor  =  ! this . canvasColor  ||  this . canvasColor  ==  'default'  ? '#e6e6e6'  : typeof  this . canvasColor  ===  'string'  ? this . canvasColor  : '' ; 
538+       this . setSize ( ) ; 
539+       this . canvas . style . backgroundColor  =  ! this . canvasColor  ||  this . canvasColor  ==  'default'  ? 'transparent'  : typeof  this . canvasColor  ===  'string'  ? this . canvasColor  : '' ; 
513540      this . ctx  =  this . canvas . getContext ( '2d' ) ; 
514541      this . originalImage  =  null ; 
515542      this . img  =  null ; 
@@ -581,6 +608,14 @@ var component = { render: function render() {
581608        supportDetection : this . supportDetection 
582609      } ) ; 
583610    } , 
611+     setSize : function  setSize ( )  { 
612+       this . canvas . width  =  this . realWidth ; 
613+       this . canvas . height  =  this . realHeight ; 
614+       this . canvas . style . width  =  this . width  +  'px' ; 
615+       this . canvas . style . height  =  this . height  +  'px' ; 
616+       // this.$refs.wrapper.style.width = this.width + 'px' 
617+       // this.$refs.wrapper.style.height = this.height + 'px' 
618+     } , 
584619    rotateByStep : function  rotateByStep ( step )  { 
585620      var  orientation  =  1 ; 
586621      switch  ( step )  { 
@@ -1075,7 +1110,7 @@ var component = { render: function render() {
10751110      } 
10761111    } , 
10771112    paintBackground : function  paintBackground ( )  { 
1078-       var  backgroundColor  =  ! this . canvasColor  ||  this . canvasColor  ==  'default'  ? '#e6e6e6 '  : this . canvasColor ; 
1113+       var  backgroundColor  =  ! this . canvasColor  ||  this . canvasColor  ==  'default'  ? 'transparent '  : this . canvasColor ; 
10791114      this . ctx . fillStyle  =  backgroundColor ; 
10801115      this . ctx . clearRect ( 0 ,  0 ,  this . realWidth ,  this . realHeight ) ; 
10811116      this . ctx . fillRect ( 0 ,  0 ,  this . realWidth ,  this . realHeight ) ; 
0 commit comments