File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -95,25 +95,25 @@ export default class SignatureCanvas extends Component {
95
95
_resizeCanvas = ( ) => {
96
96
let canvasProps = this . props . canvasProps || { }
97
97
let { width, height} = canvasProps
98
+ // don't resize if the canvas has fixed width and height
99
+ if ( width && height ) {
100
+ return
101
+ }
98
102
99
- let ctx = this . _ctx
100
103
let canvas = this . _canvas
101
104
/* When zoomed out to less than 100%, for some very strange reason,
102
105
some browsers report devicePixelRatio as less than 1
103
106
and only part of the canvas is cleared then. */
104
107
let ratio = Math . max ( window . devicePixelRatio || 1 , 1 )
105
108
106
- // only change width/height if none has been passed in as a prop
107
109
if ( ! width ) {
108
110
canvas . width = canvas . offsetWidth * ratio
109
111
}
110
112
if ( ! height ) {
111
113
canvas . height = canvas . offsetHeight * ratio
112
114
}
113
- if ( ! width || ! height ) {
114
- ctx . scale ( ratio , ratio )
115
- this . clear ( )
116
- }
115
+ canvas . getContext ( '2d' ) . scale ( ratio , ratio )
116
+ this . clear ( )
117
117
}
118
118
119
119
_reset = ( ) => {
You can’t perform that action at this time.
0 commit comments