Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
almothafar committed Dec 23, 2020
1 parent 64939d7 commit efbd049
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ API is identical to [szimek/signature_pad](https://www.npmjs.com/package/signatu
Options are as per [szimek/signature_pad](https://www.npmjs.com/package/signature_pad) with the following additions:
* canvasWidth: width of the canvas (px)
* canvasHeight: height of the canvas (px)
The above options are provided to avoid accessing the DOM directly from your component to adjust the canvas size.
The above options are provided to avoid accessing the DOM directly from your component to adjust the canvas size.

```typescript

Expand All @@ -36,20 +36,21 @@ import { SignaturePadModule } from '@almothafar/angular-signature-pad';
// then import for use in a component

import { Component, ViewChild } from '@angular/core';
import { SignaturePad } from '@almothafar/angular-signature-pad';
import { SignaturePadComponent } from '@almothafar/angular-signature-pad';

@Component({
template: '<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>'
template: '<signature-pad #signature [options]="signaturePadOptions" (drawStart)="drawStart($event)" (drawEnd)="drawComplete($event)"></signature-pad>'
})

export class SignaturePadPage {

@ViewChild(SignaturePad) signaturePad: SignaturePad;
@ViewChild('signature')
public signaturePad: SignaturePadComponent;

private signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
private signaturePadOptions: NgSignaturePadOptions = { // passed through to szimek/signature_pad constructor
minWidth: 5,
canvasWidth: 500,
canvasHeight: 300
};

constructor() {
Expand All @@ -62,14 +63,15 @@ export class SignaturePadPage {
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}

drawComplete() {
drawComplete(event: MouseEvent | Touch) {
// will be notified of szimek/signature_pad's onEnd event
console.log('Completed drawing', event);
console.log(this.signaturePad.toDataURL());
}

drawStart() {
drawStart(event: MouseEvent | Touch) {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
console.log('Start drawing', event);
}
}
```
22 changes: 12 additions & 10 deletions projects/angular-signature-pad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ import { SignaturePadModule } from '@almothafar/angular-signature-pad';
// then import for use in a component

import { Component, ViewChild } from '@angular/core';
import { SignaturePad } from '@almothafar/angular-signature-pad';
import { SignaturePadComponent } from '@almothafar/angular-signature-pad';

@Component({
template: '<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>'
template: '<signature-pad #signature [options]="signaturePadOptions" (drawStart)="drawStart($event)" (drawEnd)="drawComplete($event)"></signature-pad>'
})

export class SignaturePadPage {

@ViewChild(SignaturePad) signaturePad: SignaturePad;
@ViewChild('signature')
public signaturePad: SignaturePadComponent;

private signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
'minWidth': 5,
'canvasWidth': 500,
'canvasHeight': 300
private signaturePadOptions: NgSignaturePadOptions = { // passed through to szimek/signature_pad constructor
minWidth: 5,
canvasWidth: 500,
canvasHeight: 300
};

constructor() {
Expand All @@ -62,14 +63,15 @@ export class SignaturePadPage {
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}

drawComplete() {
drawComplete(event: MouseEvent | Touch) {
// will be notified of szimek/signature_pad's onEnd event
console.log('Completed drawing', event);
console.log(this.signaturePad.toDataURL());
}

drawStart() {
drawStart(event: MouseEvent | Touch) {
// will be notified of szimek/signature_pad's onBegin event
console.log('begin drawing');
console.log('Start drawing', event);
}
}
```

0 comments on commit efbd049

Please sign in to comment.