From 17ce94f343f58c26ac1237c8ef9945bba9d3f4d1 Mon Sep 17 00:00:00 2001 From: Peng Jie Date: Thu, 31 Oct 2019 14:32:34 +0800 Subject: [PATCH] fix(component): add more options args for `fromDataURL` method --- README.md | 31 ++++++++++++++++--------------- src/components/VueSignaturePad.js | 6 ++++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5f8df98c..0a11d2b3 100644 --- a/README.md +++ b/README.md @@ -97,21 +97,22 @@ export default { ## Methods -| Name | Argument Type | Description | -| :---------------------------------- | :------------------- | --------------------------------------------------------------------------- | -| `saveSignature()` | - | Will return target canvas **status** and **data**. | -| `undoSignature()` | - | Undo | -| `clearSignature()` | - | Clear | -| `mergeImageAndSignature(signature)` | `Object` or `String` | Provide `images` as props and will merge with signature. | -| `addImages(images)` | `Array` | Provide the images merge with signature. Reference above `images` property. | -| `lockSignaturePad()` | - | Lock target signature pad. | -| `openSignaturePad()` | - | Open target signature pad. | -| `getPropImagesAndCacheImages()` | - | Get all the images information. | -| `clearCacheImages()` | - | Clear cache images. | -| `fromDataURL(data)` | `String` | Draw image from data URL. | -| `fromData(data)` | `String` | Returns signature image as an array of point groups. | -| `toData()` | - | Draws signature image from an array of point groups. | -| `isEmpty()` | - | Return signature canvas have data. | +| Name | Argument Type | Description | +| :------------------------------------- | :--------------------------- | --------------------------------------------------------------------------- | +| `saveSignature()` | - | Will return target canvas **status** and **data**. | +| `undoSignature()` | - | Undo | +| `clearSignature()` | - | Clear | +| `mergeImageAndSignature(signature)` | `Object` or `String` | Provide `images` as props and will merge with signature. | +| `addImages(images)` | `Array` | Provide the images merge with signature. Reference above `images` property. | +| `lockSignaturePad()` | - | Lock target signature pad. | +| `openSignaturePad()` | - | Open target signature pad. | +| `getPropImagesAndCacheImages()` | - | Get all the images information. | +| `clearCacheImages()` | - | Clear cache images. | +| `fromDataURL(data, options, callback)` | `(String, Object, callback)` | Draw image from data URL. | +| `fromData(data)` | `String` | Returns signature image as an array of point groups. | +| `toData()` | - | Draws signature image from an array of point groups. | +| `isEmpty()` | - | Return signature canvas have data. | + ## Credits diff --git a/src/components/VueSignaturePad.js b/src/components/VueSignaturePad.js index d046742b..bd08fbbf 100644 --- a/src/components/VueSignaturePad.js +++ b/src/components/VueSignaturePad.js @@ -65,9 +65,11 @@ export default { const canvas = this.$refs.signaturePadCanvas; const data = this.signaturePad.toData(); const ratio = Math.max(window.devicePixelRatio || 1, 1); + canvas.width = canvas.offsetWidth * ratio; canvas.height = canvas.offsetHeight * ratio; canvas.getContext('2d').scale(ratio, ratio); + this.signaturePad.clear(); this.signatureData = TRANSPARENT_PNG; this.signaturePad.fromData(data); @@ -120,8 +122,8 @@ export default { this.signatureData ]); }, - fromDataURL(data) { - return this.signaturePad.fromDataURL(data); + fromDataURL(data, options = {}, callback) { + return this.signaturePad.fromDataURL(data, options, callback); }, fromData(data) { return this.signaturePad.fromData(data);