Skip to content

Commit

Permalink
fix(component): add more options args for fromDataURL method (#170)
Browse files Browse the repository at this point in the history
fix(component): add more options args for `fromDataURL` method
  • Loading branch information
neighborhood999 authored Oct 31, 2019
2 parents e7f4511 + 17ce94f commit 4746b94
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions src/components/VueSignaturePad.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4746b94

Please sign in to comment.