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