diff --git a/src/signature_pad.js b/src/signature_pad.js index 65bc7b8e..7f2da0de 100644 --- a/src/signature_pad.js +++ b/src/signature_pad.js @@ -154,6 +154,13 @@ SignaturePad.prototype._strokeBegin = function (event) { }; SignaturePad.prototype._strokeUpdate = function (event) { + if (this._data.length === 0) { + // This can happen if clear() was called while a signature is still in progress, + // or if there is a race condition between start/update events. + this._strokeBegin(event) + return + } + const x = event.clientX; const y = event.clientY;