The issue I’m experiencing is present with multiple 3rd party components that use the Canvas element. I’m trying to capture a signature using Kendo UI signature component and @almothafar/angular-signature-pad - npm
Touch is not being registered in the place it actually occurs as you can see below
With @almothafar/angular-signature-pad - npm I’ve created a brand new Ionic Angular app and added the component to the home page
ionic start
npm install @almothafar/angular-signature-pad --save
Modify the home page as follows;
import { NgSignaturePadOptions } from '@almothafar/angular-signature-pad';
import { Component, ViewChild } from '@angular/core';
import { SignaturePadComponent } from '@almothafar/angular-signature-pad';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
standalone: false,
})
export class HomePage {
@ViewChild('signature')
public signaturePad!: SignaturePadComponent;
public signaturePadOptions: NgSignaturePadOptions = { // passed through to szimek/signature_pad constructor
minWidth: 5,
canvasWidth: 300,
canvasHeight: 300,
backgroundColor : "white"
};
constructor() {
// no-op
}
ngAfterViewInit() {
// this.signaturePad is now available
this.signaturePad.set('minWidth', 5); // set szimek/signature_pad options at runtime
this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
}
drawComplete(event: MouseEvent | Touch | Event) {
// will be notified of szimek/signature_pad's onEnd event
console.log('Completed drawing', event);
console.log(this.signaturePad.toDataURL());
}
drawStart(event: MouseEvent | Touch | Event) {
// will be notified of szimek/signature_pad's onBegin event
console.log('Start drawing', event);
}
}
The template
<signature-pad #signature [options]="signaturePadOptions" (drawStart)="drawStart($event)" (drawEnd)="drawComplete($event)"></signature-pad>
The end result is the drawing on the canvas does not register the touch in the correct place but is misaligned. I have the same experience with the Knedo UI component, which I raised with that team and they believe it’s an issue with the Ionic framework.