Skip to content

Commit 81e426c

Browse files
lopisagilgur5
authored andcommitted
(fix): fix broken dotSize function
backport v0.2.2 bugfix from 342ce96 - this fixes an error that occurred when drawing a single dot that would result in the canvas looking empty and the state of the component containing a blank image - this error was introduced in the v0.1.6 release that made dotSize a static function instead of defined in the constructor - (props to @kgram for catching this in #11)
1 parent bb3b56e commit 81e426c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ used in drawing. All props are **optional**.
4242
- `minWidth` : `number`, default: `0.5`
4343
- `maxWidth` : `number`, default: `2.5`
4444
- `dotSize` : `number` or `function`,
45-
default: `() => (this.props.minWidth + this.props.maxWidth) / 2`
45+
default: `(minWidth, maxWidth) => (minWidth + maxWidth) / 2`
4646
- `penColor` : `string`, default: `'black'`
4747

4848
There are also two callbacks that will be called when a stroke ends and one

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default class SignatureCanvas extends Component {
2121
velocityFilterWeight: 0.7,
2222
minWidth: 0.5,
2323
maxWidth: 2.5,
24-
dotSize: () => {
25-
return (this.props.minWidth + this.props.maxWidth) / 2
24+
dotSize: (minWidth, maxWidth) => {
25+
return (minWidth + maxWidth) / 2
2626
},
2727
penColor: 'black',
2828
backgroundColor: 'rgba(0,0,0,0)',
@@ -198,7 +198,7 @@ export default class SignatureCanvas extends Component {
198198
_strokeDraw = (point) => {
199199
let ctx = this._ctx
200200
let dotSize = typeof(this.props.dotSize) === 'function'
201-
? this.props.dotSize()
201+
? this.props.dotSize(this.props.minWidth, this.props.maxWidth)
202202
: this.props.dotSize
203203

204204
ctx.beginPath();

0 commit comments

Comments
 (0)