Skip to content

Commit

Permalink
docs: don't redo after new mark is made
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech authored Apr 3, 2024
1 parent 1440699 commit d5e84d6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ function dataURLToBlob(dataURL) {
return new Blob([uInt8Array], { type: contentType });
}

signaturePad.addEventListener("endStroke", () => {
// clear undoData when new data is added
undoData = [];
});

clearButton.addEventListener("click", () => {
signaturePad.clear();
});
Expand All @@ -87,8 +92,9 @@ undoButton.addEventListener("click", () => {
const data = signaturePad.toData();

if (data && data.length > 0) {
const remove = data.pop(); // remove the last dot or line
undoData.push(remove);
// remove the last dot or line
const removed = data.pop();
undoData.push(removed);
signaturePad.fromData(data);
}
});
Expand Down

0 comments on commit d5e84d6

Please sign in to comment.