@syncfusion/ej2-inputs 31.1.17 → 31.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-inputs.min.js +2 -2
- package/dist/ej2-inputs.umd.min.js +2 -2
- package/dist/ej2-inputs.umd.min.js.map +1 -1
- package/dist/es6/ej2-inputs.es2015.js +11 -3
- package/dist/es6/ej2-inputs.es2015.js.map +1 -1
- package/dist/es6/ej2-inputs.es5.js +11 -3
- package/dist/es6/ej2-inputs.es5.js.map +1 -1
- package/dist/global/ej2-inputs.min.js +2 -2
- package/dist/global/ej2-inputs.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +11 -61
- package/src/color-picker/color-picker.js +4 -3
- package/src/textbox/textbox.js +7 -0
- package/styles/bootstrap4-lite.css +2 -2
- package/styles/bootstrap4.css +2 -2
- package/styles/bootstrap5-dark-lite.css +2 -2
- package/styles/bootstrap5-dark.css +2 -2
- package/styles/bootstrap5-lite.css +2 -2
- package/styles/bootstrap5.css +2 -2
- package/styles/input/_bootstrap4-definition.scss +1 -1
- package/styles/input/_bootstrap5-definition.scss +1 -1
- package/styles/input/bootstrap4.css +2 -2
- package/styles/input/bootstrap5-dark.css +2 -2
- package/styles/input/bootstrap5.css +2 -2
- package/dist/ts/color-picker/color-picker-model.d.ts +0 -186
- package/dist/ts/color-picker/color-picker.d.ts +0 -398
- package/dist/ts/color-picker/color-picker.ts +0 -2209
- package/dist/ts/color-picker/index.d.ts +0 -5
- package/dist/ts/color-picker/index.ts +0 -5
- package/dist/ts/common/index.d.ts +0 -4
- package/dist/ts/common/index.ts +0 -4
- package/dist/ts/common/signature-base.d.ts +0 -340
- package/dist/ts/common/signature-base.ts +0 -1170
- package/dist/ts/form-validator/form-validator-model.d.ts +0 -121
- package/dist/ts/form-validator/form-validator.d.ts +0 -312
- package/dist/ts/form-validator/form-validator.ts +0 -1068
- package/dist/ts/form-validator/index.d.ts +0 -5
- package/dist/ts/form-validator/index.ts +0 -5
- package/dist/ts/index.d.ts +0 -18
- package/dist/ts/index.ts +0 -18
- package/dist/ts/input/index.d.ts +0 -4
- package/dist/ts/input/index.ts +0 -4
- package/dist/ts/input/input.d.ts +0 -345
- package/dist/ts/input/input.ts +0 -1277
- package/dist/ts/maskedtextbox/base/index.d.ts +0 -4
- package/dist/ts/maskedtextbox/base/index.ts +0 -4
- package/dist/ts/maskedtextbox/base/mask-base.d.ts +0 -134
- package/dist/ts/maskedtextbox/base/mask-base.ts +0 -1207
- package/dist/ts/maskedtextbox/index.d.ts +0 -5
- package/dist/ts/maskedtextbox/index.ts +0 -5
- package/dist/ts/maskedtextbox/maskedtextbox/index.d.ts +0 -5
- package/dist/ts/maskedtextbox/maskedtextbox/index.ts +0 -5
- package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox-model.d.ts +0 -167
- package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.d.ts +0 -307
- package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.ts +0 -709
- package/dist/ts/numerictextbox/index.d.ts +0 -5
- package/dist/ts/numerictextbox/index.ts +0 -5
- package/dist/ts/numerictextbox/numerictextbox-model.d.ts +0 -228
- package/dist/ts/numerictextbox/numerictextbox.d.ts +0 -431
- package/dist/ts/numerictextbox/numerictextbox.ts +0 -1672
- package/dist/ts/otp-input/index.d.ts +0 -5
- package/dist/ts/otp-input/index.ts +0 -5
- package/dist/ts/otp-input/otp-input-model.d.ts +0 -165
- package/dist/ts/otp-input/otp-input.d.ts +0 -365
- package/dist/ts/otp-input/otp-input.ts +0 -924
- package/dist/ts/rating/index.d.ts +0 -5
- package/dist/ts/rating/index.ts +0 -5
- package/dist/ts/rating/rating-model.d.ts +0 -239
- package/dist/ts/rating/rating.d.ts +0 -416
- package/dist/ts/rating/rating.ts +0 -1101
- package/dist/ts/signature/index.d.ts +0 -5
- package/dist/ts/signature/index.ts +0 -5
- package/dist/ts/signature/signature-model.d.ts +0 -131
- package/dist/ts/signature/signature.d.ts +0 -167
- package/dist/ts/signature/signature.ts +0 -266
- package/dist/ts/slider/index.d.ts +0 -5
- package/dist/ts/slider/index.ts +0 -5
- package/dist/ts/slider/slider-model.d.ts +0 -401
- package/dist/ts/slider/slider.d.ts +0 -721
- package/dist/ts/slider/slider.ts +0 -3497
- package/dist/ts/smart-textarea/caret-helper.d.ts +0 -17
- package/dist/ts/smart-textarea/caret-helper.ts +0 -95
- package/dist/ts/smart-textarea/index.d.ts +0 -5
- package/dist/ts/smart-textarea/index.ts +0 -5
- package/dist/ts/smart-textarea/smart-textarea-model.d.ts +0 -44
- package/dist/ts/smart-textarea/smart-textarea.d.ts +0 -80
- package/dist/ts/smart-textarea/smart-textarea.ts +0 -518
- package/dist/ts/speech-to-text/index.d.ts +0 -5
- package/dist/ts/speech-to-text/index.ts +0 -5
- package/dist/ts/speech-to-text/speech-to-text-model.d.ts +0 -270
- package/dist/ts/speech-to-text/speech-to-text.d.ts +0 -487
- package/dist/ts/speech-to-text/speech-to-text.ts +0 -1008
- package/dist/ts/textarea/index.d.ts +0 -5
- package/dist/ts/textarea/index.ts +0 -5
- package/dist/ts/textarea/textarea-model.d.ts +0 -161
- package/dist/ts/textarea/textarea.d.ts +0 -237
- package/dist/ts/textarea/textarea.ts +0 -812
- package/dist/ts/textbox/index.d.ts +0 -5
- package/dist/ts/textbox/index.ts +0 -5
- package/dist/ts/textbox/textbox-model.d.ts +0 -155
- package/dist/ts/textbox/textbox.d.ts +0 -288
- package/dist/ts/textbox/textbox.ts +0 -872
- package/dist/ts/uploader/index.d.ts +0 -5
- package/dist/ts/uploader/index.ts +0 -5
- package/dist/ts/uploader/uploader-model.d.ts +0 -555
- package/dist/ts/uploader/uploader.d.ts +0 -1216
- package/dist/ts/uploader/uploader.ts +0 -4391
|
@@ -1,1170 +0,0 @@
|
|
|
1
|
-
import { BlazorDotnetObject, Component, removeClass } from '@syncfusion/ej2-base';
|
|
2
|
-
import { EventHandler, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
3
|
-
|
|
4
|
-
export abstract class SignatureBase extends Component<HTMLCanvasElement> {
|
|
5
|
-
/* Private variables */
|
|
6
|
-
private pointX: number;
|
|
7
|
-
private pointY: number;
|
|
8
|
-
/* time of the current point(x,y) of the corrdinates*/
|
|
9
|
-
private time: number;
|
|
10
|
-
private startPoint: Point;
|
|
11
|
-
private controlPoint1 : Point;
|
|
12
|
-
private controlPoint2 : Point;
|
|
13
|
-
private endPoint : Point;
|
|
14
|
-
private pointColl: Point[];
|
|
15
|
-
private canvasContext: CanvasRenderingContext2D;
|
|
16
|
-
private lastVelocity: number;
|
|
17
|
-
private lastWidth: number;
|
|
18
|
-
private incStep: number;
|
|
19
|
-
private snapColl: string[];
|
|
20
|
-
/* minDistance(distance between the two point) was calaculated for smoothness.*/
|
|
21
|
-
private minDistance: number = 5;
|
|
22
|
-
private previous: number = 0;
|
|
23
|
-
/* interval handles for the smoothness in the mouse move event.*/
|
|
24
|
-
private interval: number = 30;
|
|
25
|
-
private timeout: number | null = null;
|
|
26
|
-
private storedArgs: MouseEvent & TouchEvent;
|
|
27
|
-
private isSignatureEmpty: boolean = true;
|
|
28
|
-
private backgroundLoaded: boolean | null = null;
|
|
29
|
-
private fileType: SignatureFileType;
|
|
30
|
-
private fileName: string;
|
|
31
|
-
private clearArray: number[];
|
|
32
|
-
private isBlazor: boolean = false;
|
|
33
|
-
private isResponsive: boolean = false;
|
|
34
|
-
private dotnetRef: BlazorDotnetObject;
|
|
35
|
-
private signPointsColl: Point[] = [];
|
|
36
|
-
private signRatioPointsColl: Point[] = [];
|
|
37
|
-
private tempCanvas: HTMLCanvasElement;
|
|
38
|
-
private tempContext: CanvasRenderingContext2D;
|
|
39
|
-
private canRedraw: boolean = true;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Gets or sets the background color of the component.
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
public backgroundColor: string;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Gets or sets the background image for the component.
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
public backgroundImage: string;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Gets or sets whether to disable the signature component where the opacity is set to show disabled state.
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
public disabled: boolean;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Gets or sets whether to prevent the interaction in signature component.
|
|
61
|
-
*
|
|
62
|
-
*/
|
|
63
|
-
public isReadOnly: boolean;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Gets or sets whether to save the signature along with Background Color and background Image while saving.
|
|
67
|
-
*
|
|
68
|
-
*/
|
|
69
|
-
public saveWithBackground: boolean;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Gets or sets the stroke color of the signature.
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
public strokeColor: string;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Gets or sets the minimum stroke width for signature.
|
|
79
|
-
*
|
|
80
|
-
*/
|
|
81
|
-
public minStrokeWidth: number;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Gets or sets the maximum stroke width for signature.
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
public maxStrokeWidth: number;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Gets or sets the velocity to calculate the stroke thickness based on the pressure of the contact on the digitizer surface.
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
public velocity: number;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Gets or sets the last signature url to maintain the persist state.
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
public signatureValue: string;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* To Initialize the component rendering
|
|
103
|
-
*
|
|
104
|
-
* @private
|
|
105
|
-
* @param {HTMLCanvasElement} element - Specifies the canvas element.
|
|
106
|
-
* @param {BlazorDotnetObject} dotnetRef - Specifies for blazor client to server communication.
|
|
107
|
-
* @returns {void}
|
|
108
|
-
*/
|
|
109
|
-
public initialize(element: HTMLCanvasElement, dotnetRef?: BlazorDotnetObject): void {
|
|
110
|
-
this.clearArray = [];
|
|
111
|
-
this.element = element;
|
|
112
|
-
this.canvasContext = this.element.getContext('2d');
|
|
113
|
-
this.canvasContext.canvas.tabIndex = -1;
|
|
114
|
-
if (dotnetRef) {
|
|
115
|
-
this.dotnetRef = dotnetRef;
|
|
116
|
-
this.isBlazor = true;
|
|
117
|
-
if (this.signatureValue) {
|
|
118
|
-
this.loadPersistedSignature();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
this.setHTMLProperties();
|
|
122
|
-
if (isNullOrUndefined(this.signatureValue)) {
|
|
123
|
-
this.updateSnapCollection(true);
|
|
124
|
-
}
|
|
125
|
-
this.wireEvents();
|
|
126
|
-
if (!this.isBlazor) {
|
|
127
|
-
this.trigger('created', null);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private wireEvents(): void {
|
|
132
|
-
if (isNullOrUndefined(this.pointColl) && !this.isReadOnly && !this.disabled) {
|
|
133
|
-
EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
|
|
134
|
-
EventHandler.add(this.canvasContext.canvas, 'keydown', this.keyboardHandler, this);
|
|
135
|
-
window.addEventListener('resize', this.resizeHandler.bind(this));
|
|
136
|
-
} else if (this.pointColl) {
|
|
137
|
-
EventHandler.add(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler, this);
|
|
138
|
-
EventHandler.add(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler, this);
|
|
139
|
-
EventHandler.add(document, 'mouseup', this.mouseUpHandler, this);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private unwireEvents(type: string): void {
|
|
144
|
-
if (type === 'mouseup' || type === 'touchend') {
|
|
145
|
-
if (this.canvasContext) {
|
|
146
|
-
EventHandler.remove(this.canvasContext.canvas, 'mousemove touchmove', this.mouseMoveHandler);
|
|
147
|
-
EventHandler.remove(this.canvasContext.canvas, 'mouseup touchend', this.mouseUpHandler);
|
|
148
|
-
}
|
|
149
|
-
EventHandler.remove(document, 'mouseup', this.mouseUpHandler);
|
|
150
|
-
} else {
|
|
151
|
-
if (this.canvasContext) {
|
|
152
|
-
EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
|
|
153
|
-
EventHandler.remove(this.canvasContext.canvas, 'keydown', this.keyboardHandler);
|
|
154
|
-
}
|
|
155
|
-
window.removeEventListener('resize', this.resizeHandler);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
private setHTMLProperties(): void {
|
|
160
|
-
// eslint-disable-next-line max-len
|
|
161
|
-
if (this.element.height === 150 && this.element.width === 300 && this.element.offsetHeight !== 0 && this.element.offsetWidth !== 0) {
|
|
162
|
-
this.element.height = this.element.offsetHeight;
|
|
163
|
-
this.element.width = this.element.offsetWidth;
|
|
164
|
-
this.isResponsive = true;
|
|
165
|
-
} else if ((this.element.height !== this.element.offsetHeight - 1 || this.element.width !== this.element.offsetWidth - 1)
|
|
166
|
-
&& this.element.offsetHeight !== 0 && this.element.offsetWidth !== 0) {
|
|
167
|
-
this.element.height = this.element.offsetHeight;
|
|
168
|
-
this.element.width = this.element.offsetWidth;
|
|
169
|
-
}
|
|
170
|
-
this.canvasContext.fillStyle = this.strokeColor;
|
|
171
|
-
this.tempCanvas = this.createElement('canvas', { className: 'e-' + this.getModuleName() + '-temp' });
|
|
172
|
-
this.tempContext = this.tempCanvas.getContext('2d');
|
|
173
|
-
this.tempCanvas.width = this.element.width;
|
|
174
|
-
this.tempCanvas.height = this.element.height;
|
|
175
|
-
if (this.backgroundImage) {
|
|
176
|
-
this.canvasContext.canvas.style.backgroundImage = 'url(' + this.backgroundImage + ')';
|
|
177
|
-
this.canvasContext.canvas.style.backgroundRepeat = 'no-repeat';
|
|
178
|
-
if (this.saveWithBackground) {
|
|
179
|
-
this.setBackgroundImage(this.backgroundImage, 'temp');
|
|
180
|
-
}
|
|
181
|
-
} else if (this.backgroundColor) {
|
|
182
|
-
this.canvasContext.canvas.style.backgroundColor = this.backgroundColor;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
protected mouseDownHandler(e : MouseEvent & TouchEvent): void {
|
|
187
|
-
if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchstart') {
|
|
188
|
-
if (e.type === 'touchstart') {
|
|
189
|
-
e.preventDefault();
|
|
190
|
-
e.stopPropagation();
|
|
191
|
-
}
|
|
192
|
-
this.beginStroke(e);
|
|
193
|
-
this.wireEvents();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private mouseMoveHandler(e: MouseEvent & TouchEvent): void {
|
|
198
|
-
if (e.buttons === 1 || e.buttons === 2 || e.type === 'touchmove') {
|
|
199
|
-
if (e.type === 'touchmove') {
|
|
200
|
-
e.preventDefault();
|
|
201
|
-
e.stopPropagation();
|
|
202
|
-
}
|
|
203
|
-
if (this.interval) {
|
|
204
|
-
this.updateStrokeWithThrottle(e);
|
|
205
|
-
} else {
|
|
206
|
-
this.updateStroke(e);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
private mouseUpHandler(e: MouseEvent & TouchEvent): void {
|
|
212
|
-
const args: SignatureChangeEventArgs = { actionName: 'strokeUpdate'};
|
|
213
|
-
if (e.type === 'touchstart') {
|
|
214
|
-
e.preventDefault();
|
|
215
|
-
e.stopPropagation();
|
|
216
|
-
}
|
|
217
|
-
this.endDraw();
|
|
218
|
-
this.updateSnapCollection();
|
|
219
|
-
this.unwireEvents(e.type);
|
|
220
|
-
if (!this.isBlazor) {
|
|
221
|
-
this.trigger('change', args);
|
|
222
|
-
} else {
|
|
223
|
-
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'mouseUp');
|
|
224
|
-
}
|
|
225
|
-
this.signatureValue = this.snapColl[this.incStep];
|
|
226
|
-
for (let i: number = 0; i < this.signPointsColl.length; i++) {
|
|
227
|
-
this.signRatioPointsColl.push({ x: (this.signPointsColl[i as number].x / this.canvasContext.canvas.width),
|
|
228
|
-
y: (this.signPointsColl[i as number].y / this.canvasContext.canvas.height)});
|
|
229
|
-
}
|
|
230
|
-
this.signPointsColl = [];
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private keyboardHandler(e : KeyboardEvent): void {
|
|
234
|
-
const args: SignatureBeforeSaveEventArgs = {fileName: 'Signature', type: 'Png', cancel: false};
|
|
235
|
-
switch (e.key) {
|
|
236
|
-
case 'Delete':
|
|
237
|
-
this.clear();
|
|
238
|
-
break;
|
|
239
|
-
case (e.ctrlKey && 's'):
|
|
240
|
-
if (!this.isBlazor) {
|
|
241
|
-
this.trigger('beforeSave', args, (observableSaveArgs: SignatureBeforeSaveEventArgs) => {
|
|
242
|
-
if (!args.cancel) {
|
|
243
|
-
this.save(observableSaveArgs.type, observableSaveArgs.fileName);
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
} else {
|
|
247
|
-
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'beforeSave');
|
|
248
|
-
}
|
|
249
|
-
e.preventDefault();
|
|
250
|
-
e.stopImmediatePropagation();
|
|
251
|
-
break;
|
|
252
|
-
case (e.ctrlKey && 'z'):
|
|
253
|
-
this.undo();
|
|
254
|
-
break;
|
|
255
|
-
case (e.ctrlKey && 'y'):
|
|
256
|
-
this.redo();
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
private resizeHandler(): void {
|
|
262
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
263
|
-
const proxy: SignatureBase = this;
|
|
264
|
-
if (this.isResponsive && this.canRedraw && this.canvasContext && this.element) {
|
|
265
|
-
this.canvasContext.canvas.width = this.element.offsetWidth;
|
|
266
|
-
this.canvasContext.canvas.height = this.element.offsetHeight;
|
|
267
|
-
this.canvasContext.scale(1, 1);
|
|
268
|
-
this.canvasContext.fillStyle = this.strokeColor;
|
|
269
|
-
const pointSize: number = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
|
|
270
|
-
for (let i: number = 0; i < this.signRatioPointsColl.length; i++) {
|
|
271
|
-
this.arcDraw((this.signRatioPointsColl[i as number].x * this.canvasContext.canvas.width),
|
|
272
|
-
(this.signRatioPointsColl[i as number].y * this.canvasContext.canvas.height), pointSize);
|
|
273
|
-
}
|
|
274
|
-
this.signPointsColl = [];
|
|
275
|
-
this.canvasContext.closePath();
|
|
276
|
-
this.canvasContext.fill();
|
|
277
|
-
}
|
|
278
|
-
else if (this.canvasContext && this.element) {
|
|
279
|
-
const restoreImg: HTMLImageElement = new Image();
|
|
280
|
-
restoreImg.src = this.snapColl[this.incStep];
|
|
281
|
-
restoreImg.onload = () => {
|
|
282
|
-
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
283
|
-
proxy.canvasContext.drawImage(restoreImg, 0, 0, proxy.element.width, proxy.element.height);
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
private beginStroke(e : MouseEvent & TouchEvent): void {
|
|
289
|
-
this.internalRefresh();
|
|
290
|
-
this.updateStroke(e);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
private updateStroke(e : MouseEvent & TouchEvent): void {
|
|
294
|
-
const point: Point = this.createPoint(e);
|
|
295
|
-
this.addPoint(point);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
private updateStrokeWithThrottle(args: MouseEvent & TouchEvent): void {
|
|
299
|
-
const now: number = Date.now();
|
|
300
|
-
const remaining: number = this.interval - (now - this.previous);
|
|
301
|
-
this.storedArgs = args;
|
|
302
|
-
if (remaining <= 0 || remaining > this.interval) {
|
|
303
|
-
if (this.timeout) {
|
|
304
|
-
clearTimeout(this.timeout);
|
|
305
|
-
this.timeout = null;
|
|
306
|
-
}
|
|
307
|
-
this.previous = now;
|
|
308
|
-
this.updateStroke(this.storedArgs);
|
|
309
|
-
if (!this.timeout) {
|
|
310
|
-
this.storedArgs = null;
|
|
311
|
-
}
|
|
312
|
-
} else if (!this.timeout) {
|
|
313
|
-
this.timeout = window.setTimeout(this.delay.bind(this), remaining);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
private delay(): void {
|
|
318
|
-
this.previous = Date.now();
|
|
319
|
-
this.timeout = null;
|
|
320
|
-
this.updateStroke(this.storedArgs);
|
|
321
|
-
if (!this.timeout) {
|
|
322
|
-
this.storedArgs = null;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
private createPoint(e: MouseEvent & TouchEvent): Point {
|
|
327
|
-
const rect: DOMRect = this.canvasContext.canvas.getBoundingClientRect() as DOMRect;
|
|
328
|
-
if (e.type === 'mousedown' || e.type === 'mousemove') {
|
|
329
|
-
return this.point(e.clientX - rect.left, e.clientY - rect.top, new Date().getTime());
|
|
330
|
-
} else {
|
|
331
|
-
return this.point(e.touches[0].clientX - rect.left, e.touches[0].clientY - rect.top, new Date().getTime());
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/* Returns the current point corrdinates(x, y) and time.*/
|
|
336
|
-
private point(pointX: number, pointY: number, time: number): Point {
|
|
337
|
-
this.pointX = pointX;
|
|
338
|
-
this.pointY = pointY;
|
|
339
|
-
this.time = time || new Date().getTime();
|
|
340
|
-
return { x: this.pointX, y: this.pointY, time: this.time };
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
private addPoint(point: Point): void {
|
|
344
|
-
const points: Point[] = this.pointColl; let controlPoint1: Point; let controlPoint2: Point;
|
|
345
|
-
const lastPoint: Point = points.length > 0 && points[points.length - 1];
|
|
346
|
-
const isLastPointTooClose: boolean = lastPoint ? this.distanceTo(lastPoint) <= this.minDistance : false;
|
|
347
|
-
if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
|
|
348
|
-
points.push(point);
|
|
349
|
-
if (points.length > 2) {
|
|
350
|
-
if (points.length === 3) {
|
|
351
|
-
points.unshift(points[0]);
|
|
352
|
-
}
|
|
353
|
-
controlPoint1 = (this.calculateCurveControlPoints(points[0], points[1], points[2])).controlPoint2;
|
|
354
|
-
controlPoint2 = (this.calculateCurveControlPoints(points[1], points[2], points[3])).controlPoint1;
|
|
355
|
-
this.startPoint = points[1]; this.controlPoint1 = controlPoint1;
|
|
356
|
-
this.controlPoint2 = controlPoint2; this.endPoint = points[2];
|
|
357
|
-
this.startDraw();
|
|
358
|
-
points.shift();
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
private startDraw(): void {
|
|
364
|
-
let velocity: number;
|
|
365
|
-
velocity = this.pointVelocityCalc(this.startPoint);
|
|
366
|
-
velocity = this.velocity * velocity + (1 - this.velocity) * this.lastVelocity;
|
|
367
|
-
const newWidth: number = Math.max(this.maxStrokeWidth / (velocity + 1), this.minStrokeWidth);
|
|
368
|
-
this.curveDraw(this.lastWidth, newWidth);
|
|
369
|
-
this.lastVelocity = velocity;
|
|
370
|
-
this.lastWidth = newWidth;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
private endDraw(): void {
|
|
374
|
-
if (isNullOrUndefined(this.pointColl)) { return; }
|
|
375
|
-
const canDrawCurve: boolean = this.pointColl.length > 2; const point: Point = this.pointColl[0];
|
|
376
|
-
if (!canDrawCurve && point) {
|
|
377
|
-
this.strokeDraw(point);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/* Calculate the Bezier (x, y) coordinate of the curve. */
|
|
382
|
-
private curveDraw(startWidth: number, endWidth: number): void {
|
|
383
|
-
const context: CanvasRenderingContext2D = this.canvasContext;
|
|
384
|
-
let width: number; let i: number; let t1: number; let t2: number;
|
|
385
|
-
let t3: number; let u1: number; let u2: number; let u3: number; let x: number; let y: number;
|
|
386
|
-
const widthValue: number = endWidth - startWidth;
|
|
387
|
-
const bezierLength: number = this.bezierLengthCalc();
|
|
388
|
-
const drawSteps : number = Math.ceil(bezierLength) * 2;
|
|
389
|
-
context.beginPath();
|
|
390
|
-
for (i = 0; i < drawSteps; i++) {
|
|
391
|
-
t1 = i / drawSteps; t2 = t1 * t1; t3 = t2 * t1;
|
|
392
|
-
u1 = 1 - t1; u2 = u1 * u1; u3 = u2 * u1;
|
|
393
|
-
x = u3 * this.startPoint.x; x += 3 * u2 * t1 * this.controlPoint1.x;
|
|
394
|
-
x += 3 * u1 * t2 * this.controlPoint2.x; x += t3 * this.endPoint.x;
|
|
395
|
-
y = u3 * this.startPoint.y; y += 3 * u2 * t1 * this.controlPoint1.y;
|
|
396
|
-
y += 3 * u1 * t2 * this.controlPoint2.y; y += t3 * this.endPoint.y;
|
|
397
|
-
width = Math.min(startWidth + t3 * widthValue, this.maxStrokeWidth);
|
|
398
|
-
this.arcDraw(x, y, width);
|
|
399
|
-
}
|
|
400
|
-
context.closePath();
|
|
401
|
-
context.fill();
|
|
402
|
-
this.isSignatureEmpty = false;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
private strokeDraw(point: Point): void {
|
|
406
|
-
const context: CanvasRenderingContext2D = this.canvasContext;
|
|
407
|
-
const pointSize: number = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
|
|
408
|
-
context.beginPath();
|
|
409
|
-
this.arcDraw( point.x, point.y, pointSize);
|
|
410
|
-
context.closePath();
|
|
411
|
-
context.fill();
|
|
412
|
-
this.isSignatureEmpty = false;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
private arcDraw(x: number, y: number, size: number): void {
|
|
416
|
-
this.signPointsColl.push({x: x, y: y});
|
|
417
|
-
const context: CanvasRenderingContext2D = this.canvasContext;
|
|
418
|
-
context.moveTo(x, y);
|
|
419
|
-
context.arc(x, y, size, 0, 2 * Math.PI, false);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/* Utility functions for Bezier algorithm*/
|
|
423
|
-
private calculateCurveControlPoints(p1: Point, p2: Point, p3: Point): {controlPoint1: Point, controlPoint2: Point} {
|
|
424
|
-
const dx1: number = p1.x - p2.x; const dy1: number = p1.y - p2.y;
|
|
425
|
-
const dx2: number = p2.x - p3.x; const dy2: number = p2.y - p3.y;
|
|
426
|
-
const m1: Point = { x: (p1.x + p2.x) / 2.0, y: (p1.y + p2.y) / 2.0 };
|
|
427
|
-
const m2: Point = { x: (p2.x + p3.x) / 2.0, y: (p2.y + p3.y) / 2.0 };
|
|
428
|
-
const l1: number = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
|
429
|
-
const l2: number = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
430
|
-
const dxm: number = (m1.x - m2.x); const dym: number = (m1.y - m2.y);
|
|
431
|
-
const k: number = l2 / (l1 + l2);
|
|
432
|
-
const cm: Point = { x: m2.x + dxm * k, y: m2.y + dym * k };
|
|
433
|
-
const tx: number = p2.x - cm.x; const ty: number = p2.y - cm.y;
|
|
434
|
-
return {
|
|
435
|
-
controlPoint1: this.point(m1.x + tx, m1.y + ty, 0),
|
|
436
|
-
controlPoint2: this.point(m2.x + tx, m2.y + ty, 0)
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/* Returns approximated bezier length of the curuve.*/
|
|
441
|
-
private bezierLengthCalc(): number {
|
|
442
|
-
const steps: number = 10; let length: number = 0; let i: number; let t: number; let pointx1: number;
|
|
443
|
-
let pointy1: number; let pointx2: number; let pointy2: number; let pointx3: number; let pointy3: number;
|
|
444
|
-
for (i = 0; i <= steps; i++) {
|
|
445
|
-
t = i / steps;
|
|
446
|
-
pointx1 = this.bezierPointCalc(t, this.startPoint.x, this.controlPoint1.x, this.controlPoint2.x, this.endPoint.x);
|
|
447
|
-
pointy1 = this.bezierPointCalc(t, this.startPoint.y, this.controlPoint1.y, this.controlPoint2.y, this.endPoint.y);
|
|
448
|
-
if (i > 0) {
|
|
449
|
-
pointx3 = pointx1 - pointx2;
|
|
450
|
-
pointy3 = pointy1 - pointy2;
|
|
451
|
-
length += Math.sqrt(pointx3 * pointx3 + pointy3 * pointy3);
|
|
452
|
-
}
|
|
453
|
-
pointx2 = pointx1;
|
|
454
|
-
pointy2 = pointy1;
|
|
455
|
-
}
|
|
456
|
-
return length;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
/* Calculate parametric value of x or y given t and the
|
|
460
|
-
four point(startpoint, controlpoint1, controlpoint2, endpoint) coordinates of a cubic bezier curve.*/
|
|
461
|
-
private bezierPointCalc(t: number, startpoint: number, cp1: number, cp2: number, endpoint: number): number {
|
|
462
|
-
return startpoint * (1.0 - t) * (1.0 - t) * (1.0 - t) + 3.0 * cp1 * (1.0 - t) * (1.0 - t) * t + 3.0 *
|
|
463
|
-
cp2 * (1.0 - t) * t * t + endpoint * t * t * t;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/* Velocity between the current point and last point.*/
|
|
467
|
-
private pointVelocityCalc(startPoint: Point): number {
|
|
468
|
-
return (this.time !== startPoint.time) ? this.distanceTo(startPoint) / (this.time - startPoint.time) : 0;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/* Distance between the current point and last point.*/
|
|
472
|
-
private distanceTo(start: Point): number {
|
|
473
|
-
return Math.sqrt(Math.pow(this.pointX - start.x, 2) + Math.pow(this.pointY - start.y, 2));
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
private isRead(isRead: boolean): void {
|
|
477
|
-
if (isRead) {
|
|
478
|
-
EventHandler.remove(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler);
|
|
479
|
-
} else if (!this.disabled) {
|
|
480
|
-
EventHandler.add(this.canvasContext.canvas, 'mousedown touchstart', this.mouseDownHandler, this);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
private enableOrDisable(isDisable: boolean): void {
|
|
485
|
-
this.disabled = isDisable;
|
|
486
|
-
if (isDisable) {
|
|
487
|
-
this.canvasContext.canvas.style.filter = 'opacity(0.5)';
|
|
488
|
-
this.isRead(true);
|
|
489
|
-
} else {
|
|
490
|
-
this.canvasContext.canvas.style.filter = '';
|
|
491
|
-
this.isRead(false);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
private updateSnapCollection(isClear?: boolean): void {
|
|
496
|
-
if (isNullOrUndefined(this.incStep)) {
|
|
497
|
-
this.incStep = -1;
|
|
498
|
-
this.incStep++;
|
|
499
|
-
this.snapColl = [];
|
|
500
|
-
this.clearArray = [];
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
this.incStep++;
|
|
504
|
-
}
|
|
505
|
-
if (this.incStep < this.snapColl.length) {
|
|
506
|
-
this.snapColl.length = this.incStep;
|
|
507
|
-
}
|
|
508
|
-
if (this.incStep > 0) {
|
|
509
|
-
const canvasNew: HTMLCanvasElement = this.createElement('canvas', { className: 'e-' + this.getModuleName() + '-wrapper' });
|
|
510
|
-
const canvasContextNew: CanvasRenderingContext2D = canvasNew.getContext('2d');
|
|
511
|
-
if (this.canvasContext) {
|
|
512
|
-
canvasNew.width = this.canvasContext.canvas.width;
|
|
513
|
-
canvasNew.height = this.canvasContext.canvas.height;
|
|
514
|
-
canvasContextNew.drawImage(this.canvasContext.canvas, 0, 0, canvasNew.width, canvasNew.height);
|
|
515
|
-
this.snapColl.push(canvasNew.toDataURL());
|
|
516
|
-
}
|
|
517
|
-
} else {
|
|
518
|
-
this.snapColl.push(this.canvasContext.canvas.toDataURL());
|
|
519
|
-
}
|
|
520
|
-
if (isClear) {
|
|
521
|
-
this.clearArray.push(this.incStep);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
private setBackgroundImage(imageSrc: string, type?: string): void {
|
|
526
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
527
|
-
const proxy: SignatureBase = this;
|
|
528
|
-
const imageObj: HTMLImageElement = new Image();
|
|
529
|
-
imageObj.crossOrigin = 'anonymous';
|
|
530
|
-
imageObj.src = imageSrc;
|
|
531
|
-
if (type === 'temp') {
|
|
532
|
-
imageObj.onload = () => {
|
|
533
|
-
proxy.tempContext.globalCompositeOperation = 'source-over';
|
|
534
|
-
proxy.tempContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
535
|
-
};
|
|
536
|
-
} else {
|
|
537
|
-
imageObj.onload = () => {
|
|
538
|
-
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
539
|
-
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
540
|
-
proxy.updateSnapCollection();
|
|
541
|
-
proxy.saveBackground(true);
|
|
542
|
-
};
|
|
543
|
-
this.canvasContext.clearRect( 0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
private setBackgroundColor(color: string): void {
|
|
548
|
-
const canvasEle: CanvasRenderingContext2D = this.canvasContext;
|
|
549
|
-
canvasEle.strokeStyle = color;
|
|
550
|
-
let i: number; let j: number;
|
|
551
|
-
for ( i = 1; i <= canvasEle.canvas.width; i++) {
|
|
552
|
-
for ( j = 1; j <= canvasEle.canvas.height; j++) {
|
|
553
|
-
canvasEle.strokeRect( 0, 0, i, j);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
this.updateSnapCollection();
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
protected loadPersistedSignature(): void {
|
|
560
|
-
if (isNullOrUndefined(this.signatureValue)) {
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
564
|
-
const proxy: SignatureBase = this;
|
|
565
|
-
const lastImage: HTMLImageElement = new Image();
|
|
566
|
-
lastImage.src = this.signatureValue;
|
|
567
|
-
lastImage.onload = () => {
|
|
568
|
-
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
569
|
-
proxy.canvasContext.drawImage(lastImage, 0, 0);
|
|
570
|
-
proxy.updateSnapCollection();
|
|
571
|
-
};
|
|
572
|
-
this.isSignatureEmpty = false;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* To get the signature as Blob.
|
|
577
|
-
*
|
|
578
|
-
* @param {string} url - specify the url/base 64 string to get blob of the signature.
|
|
579
|
-
* @returns {Blob}.
|
|
580
|
-
*/
|
|
581
|
-
|
|
582
|
-
public getBlob(url: string): Blob {
|
|
583
|
-
const arr: string[] = url.split(','); const type: string = arr[0].match(/:(.*?);/)[1];
|
|
584
|
-
const bstr: string = atob(arr[1]); let n: number = bstr.length; const u8arr: Uint8Array = new Uint8Array(n);
|
|
585
|
-
while (n--) {
|
|
586
|
-
u8arr[n as number] = bstr.charCodeAt(n);
|
|
587
|
-
}
|
|
588
|
-
return new Blob([u8arr], { type: type });
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
private download(blob: Blob, fileName: string): void {
|
|
592
|
-
const blobUrl: string = URL.createObjectURL(blob);
|
|
593
|
-
const a: HTMLAnchorElement = document.createElement('a');
|
|
594
|
-
a.href = blobUrl;
|
|
595
|
-
a.target = '_parent';
|
|
596
|
-
a.download = fileName;
|
|
597
|
-
(document.body || document.documentElement).appendChild(a);
|
|
598
|
-
a.click();
|
|
599
|
-
a.parentNode.removeChild(a);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
private internalRefresh(): void {
|
|
603
|
-
this.pointColl = [];
|
|
604
|
-
this.lastVelocity = 0;
|
|
605
|
-
this.lastWidth = (this.minStrokeWidth + this.maxStrokeWidth) / 2;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* To refresh the signature.
|
|
610
|
-
*
|
|
611
|
-
* @returns {void}.
|
|
612
|
-
*/
|
|
613
|
-
public refresh(): void {
|
|
614
|
-
this.isResponsive = false;
|
|
615
|
-
this.setHTMLProperties();
|
|
616
|
-
this.resizeHandler();
|
|
617
|
-
this.internalRefresh();
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Erases all the signature strokes signed by user.
|
|
622
|
-
*
|
|
623
|
-
* @returns {void}.
|
|
624
|
-
*/
|
|
625
|
-
|
|
626
|
-
public clear(): void {
|
|
627
|
-
const args: SignatureChangeEventArgs = { actionName: 'clear'};
|
|
628
|
-
this.canvasContext.clearRect( 0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
629
|
-
this.tempContext.clearRect( 0, 0, this.tempContext.canvas.width, this.tempContext.canvas.height);
|
|
630
|
-
if (this.saveWithBackground && this.backgroundImage) {
|
|
631
|
-
this.setBackgroundImage(this.backgroundImage, 'temp');
|
|
632
|
-
}
|
|
633
|
-
this.internalRefresh();
|
|
634
|
-
this.signRatioPointsColl = [];
|
|
635
|
-
this.updateSnapCollection(true);
|
|
636
|
-
this.isSignatureEmpty = this.canRedraw = true;
|
|
637
|
-
if (!this.isBlazor) {
|
|
638
|
-
this.trigger('change', args);
|
|
639
|
-
} else {
|
|
640
|
-
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Clear');
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* Undo the last user action.
|
|
646
|
-
*
|
|
647
|
-
* @returns {void}.
|
|
648
|
-
*/
|
|
649
|
-
|
|
650
|
-
public undo(): void {
|
|
651
|
-
const args: SignatureChangeEventArgs = { actionName: 'undo'};
|
|
652
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
653
|
-
const proxy: SignatureBase = this;
|
|
654
|
-
if (this.incStep > 0) {
|
|
655
|
-
this.incStep--;
|
|
656
|
-
const undoImg: HTMLImageElement = new Image();
|
|
657
|
-
undoImg.src = this.snapColl[this.incStep];
|
|
658
|
-
undoImg.onload = () => {
|
|
659
|
-
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
660
|
-
proxy.canvasContext.drawImage(undoImg, 0, 0, proxy.element.width, proxy.element.height);
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
this.isClear();
|
|
664
|
-
if (!this.isBlazor) {
|
|
665
|
-
this.trigger('change', args);
|
|
666
|
-
} else {
|
|
667
|
-
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Undo');
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Redo the last user action.
|
|
673
|
-
*
|
|
674
|
-
* @returns {void}.
|
|
675
|
-
*/
|
|
676
|
-
public redo(): void {
|
|
677
|
-
const args: SignatureChangeEventArgs = { actionName: 'redo'};
|
|
678
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
679
|
-
const proxy: SignatureBase = this;
|
|
680
|
-
if (this.incStep < this.snapColl.length - 1) {
|
|
681
|
-
this.incStep++;
|
|
682
|
-
const redoImg: HTMLImageElement = new Image();
|
|
683
|
-
redoImg.src = this.snapColl[this.incStep];
|
|
684
|
-
redoImg.onload = () => {
|
|
685
|
-
proxy.canvasContext.clearRect(0, 0, proxy.element.width, proxy.element.height);
|
|
686
|
-
proxy.canvasContext.drawImage(redoImg, 0, 0, proxy.element.width, proxy.element.height);
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
this.isClear();
|
|
690
|
-
if (!this.isBlazor) {
|
|
691
|
-
this.trigger('change', args);
|
|
692
|
-
} else {
|
|
693
|
-
this.dotnetRef.invokeMethodAsync('TriggerEventAsync', 'Redo');
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
private isClear(): void {
|
|
698
|
-
if (this.clearArray) {
|
|
699
|
-
let empty: boolean = false;
|
|
700
|
-
for (let i: number = 0; i < this.clearArray.length; i++) {
|
|
701
|
-
if (this.clearArray[i as number] === this.incStep) {
|
|
702
|
-
this.isSignatureEmpty = true;
|
|
703
|
-
empty = true;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
if (!empty) {
|
|
707
|
-
this.isSignatureEmpty = false;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/**
|
|
713
|
-
* To check whether the signature is empty or not.
|
|
714
|
-
*
|
|
715
|
-
* @returns {boolean}.
|
|
716
|
-
*/
|
|
717
|
-
|
|
718
|
-
public isEmpty(): boolean {
|
|
719
|
-
return this.isSignatureEmpty;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* To check whether the undo collection is empty or not.
|
|
724
|
-
*
|
|
725
|
-
* @returns {boolean}.
|
|
726
|
-
*/
|
|
727
|
-
|
|
728
|
-
public canUndo(): boolean {
|
|
729
|
-
return this.incStep > 0;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* To check whether the redo collection is empty or not.
|
|
734
|
-
*
|
|
735
|
-
* @returns {boolean}.
|
|
736
|
-
*/
|
|
737
|
-
|
|
738
|
-
public canRedo(): boolean {
|
|
739
|
-
return this.incStep < this.snapColl.length - 1;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* To draw the signature based on the given text, with the font family and font size.
|
|
744
|
-
*
|
|
745
|
-
* @param {string} text - specify text to be drawn as signature.
|
|
746
|
-
* @param {string} fontFamily - specify font family of a signature.
|
|
747
|
-
* @param {number} fontSize - specify font size of a signature.
|
|
748
|
-
* @param {number} x- Specifies the x-coordinate to start the text of a signature. Default to the center point of the image if it not specified.
|
|
749
|
-
* @param {number} y - Specifies the y-coordinate to start the text of a signature. Default to the center point of the image if it not specified.
|
|
750
|
-
*
|
|
751
|
-
* @returns {void}.
|
|
752
|
-
*/
|
|
753
|
-
|
|
754
|
-
public draw(text: string, fontFamily?: string, fontSize?: number, x?: number, y?: number): void {
|
|
755
|
-
const args: SignatureChangeEventArgs = { actionName: 'draw-text'};
|
|
756
|
-
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
757
|
-
fontFamily = fontFamily || 'Arial';
|
|
758
|
-
fontSize = fontSize || 30;
|
|
759
|
-
this.canvasContext.font = fontSize + 'px ' + fontFamily;
|
|
760
|
-
let startX: number = this.element.width / 2;
|
|
761
|
-
let startY: number = this.element.height / 2;
|
|
762
|
-
if (isNullOrUndefined(x) && isNullOrUndefined(y)) {
|
|
763
|
-
this.canvasContext.textAlign = 'center';
|
|
764
|
-
this.canvasContext.textBaseline = 'middle';
|
|
765
|
-
} else {
|
|
766
|
-
startX = isNullOrUndefined(x) ? startX : x;
|
|
767
|
-
startY = isNullOrUndefined(y) ? startY + fontSize / 2 : (y + fontSize / 2);
|
|
768
|
-
}
|
|
769
|
-
this.canvasContext.fillText(text, startX, startY);
|
|
770
|
-
this.updateSnapCollection();
|
|
771
|
-
this.isSignatureEmpty = false;
|
|
772
|
-
this.trigger('change', args);
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* To load the signature with the given base 64 string, height and width.
|
|
777
|
-
*
|
|
778
|
-
* @param {string} signature - specify the url/base 64 string to be drawn as signature.
|
|
779
|
-
* @param {number} width - specify the width of the loaded signature image.
|
|
780
|
-
* @param {number} height - specify the height of the loaded signature image.
|
|
781
|
-
* @returns {void}.
|
|
782
|
-
*/
|
|
783
|
-
|
|
784
|
-
public load(signature: string, width?: number, height?: number): void {
|
|
785
|
-
height = height || this.element.height;
|
|
786
|
-
width = width || this.element.width;
|
|
787
|
-
this.canvasContext.clearRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
788
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
789
|
-
const proxy: SignatureBase = this;
|
|
790
|
-
const bitmapImage: HTMLImageElement = new Image();
|
|
791
|
-
bitmapImage.src = signature;
|
|
792
|
-
if (signature.slice(0, 4) !== 'data') {
|
|
793
|
-
bitmapImage.crossOrigin = 'anonymous';
|
|
794
|
-
}
|
|
795
|
-
bitmapImage.onload = () => {
|
|
796
|
-
Promise.all([
|
|
797
|
-
createImageBitmap(bitmapImage, 0, 0, width, height)
|
|
798
|
-
]).then((results: ImageBitmap[]) => {
|
|
799
|
-
const tempCanvas: HTMLCanvasElement = document.createElement('canvas');
|
|
800
|
-
tempCanvas.width = width;
|
|
801
|
-
tempCanvas.height = height;
|
|
802
|
-
tempCanvas.getContext('2d').drawImage(results[0], 0, 0);
|
|
803
|
-
if (signature.slice(0, 4) !== 'data') {
|
|
804
|
-
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
805
|
-
}
|
|
806
|
-
proxy.canvasContext.drawImage(tempCanvas, 0, 0, width, height, 0, 0, proxy.element.width, proxy.element.height);
|
|
807
|
-
proxy.updateSnapCollection();
|
|
808
|
-
});
|
|
809
|
-
};
|
|
810
|
-
this.isSignatureEmpty = this.canRedraw = false;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
private saveBackground(savebg: boolean): void {
|
|
814
|
-
let imageSrc: string;
|
|
815
|
-
if (savebg && this.backgroundImage) {
|
|
816
|
-
imageSrc = this.snapColl[this.incStep - 1];
|
|
817
|
-
} else {
|
|
818
|
-
imageSrc = this.snapColl[this.incStep];
|
|
819
|
-
}
|
|
820
|
-
if (!savebg) {
|
|
821
|
-
this.canvasContext.clearRect( 0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
822
|
-
if (this.backgroundImage) {
|
|
823
|
-
this.setBackgroundImage(this.backgroundImage);
|
|
824
|
-
} else if (this.backgroundColor) {
|
|
825
|
-
this.setBackgroundColor(this.backgroundColor);
|
|
826
|
-
savebg = true;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
if (savebg) {
|
|
830
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
831
|
-
const proxy: SignatureBase = this;
|
|
832
|
-
const imageObj: HTMLImageElement = new Image();
|
|
833
|
-
imageObj.crossOrigin = 'anonymous';
|
|
834
|
-
imageObj.src = imageSrc;
|
|
835
|
-
imageObj.onload = () => {
|
|
836
|
-
proxy.backgroundLoaded = true;
|
|
837
|
-
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
838
|
-
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
839
|
-
proxy.save(proxy.fileType, proxy.fileName);
|
|
840
|
-
};
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* To save the signature with the given file type and file name.
|
|
846
|
-
*
|
|
847
|
-
* @param {SignatureFileType} type - specify type of the file to be saved a signature.
|
|
848
|
-
* @param {string} fileName - specify name of the file to be saved a signature.
|
|
849
|
-
*
|
|
850
|
-
* @returns {void}.
|
|
851
|
-
*/
|
|
852
|
-
|
|
853
|
-
public save(type?: SignatureFileType, fileName?: string): void {
|
|
854
|
-
if (this.saveWithBackground && this.backgroundLoaded == null && (this.backgroundImage || this.backgroundColor)) {
|
|
855
|
-
this.backgroundLoaded = false;
|
|
856
|
-
this.fileType = type; this.fileName = fileName;
|
|
857
|
-
this.saveBackground(false);
|
|
858
|
-
} else if (type === 'Svg') {
|
|
859
|
-
fileName = fileName || 'Signature';
|
|
860
|
-
this.toSVG(fileName);
|
|
861
|
-
} else if (type === 'Jpeg') {
|
|
862
|
-
fileName = fileName || 'Signature';
|
|
863
|
-
if (!this.saveWithBackground || this.saveWithBackground && !(this.backgroundImage || this.backgroundColor)) {
|
|
864
|
-
this.toJPEG(fileName);
|
|
865
|
-
} else {
|
|
866
|
-
const dataURL: string = this.canvasContext.canvas.toDataURL('image/jpeg');
|
|
867
|
-
this.download(this.getBlob(dataURL), fileName + '.' + 'jpeg');
|
|
868
|
-
}
|
|
869
|
-
} else {
|
|
870
|
-
fileName = fileName || 'Signature';
|
|
871
|
-
const dataURL: string = this.canvasContext.canvas.toDataURL('image/png');
|
|
872
|
-
this.download(this.getBlob(dataURL), fileName + '.' + 'png');
|
|
873
|
-
}
|
|
874
|
-
if (this.saveWithBackground && this.backgroundLoaded) {
|
|
875
|
-
this.resetSnap();
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
private resetSnap(): void {
|
|
880
|
-
this.canvasContext.clearRect( 0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
881
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
882
|
-
const proxy: SignatureBase = this;
|
|
883
|
-
const restoreObj: HTMLImageElement = new Image();
|
|
884
|
-
restoreObj.src = this.snapColl[this.incStep - 1];
|
|
885
|
-
restoreObj.onload = () => {
|
|
886
|
-
proxy.canvasContext.drawImage(restoreObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
887
|
-
proxy.updateSnapCollection();
|
|
888
|
-
};
|
|
889
|
-
this.backgroundLoaded = null;
|
|
890
|
-
this.snapColl.pop(); this.incStep--;
|
|
891
|
-
this.snapColl.pop(); this.incStep--;
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
private toJPEG(fileName: string): void {
|
|
895
|
-
const imageSrc: string = this.snapColl[this.incStep];
|
|
896
|
-
this.setBackgroundColor('#ffffff');
|
|
897
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
898
|
-
const proxy: SignatureBase = this;
|
|
899
|
-
const imageObj: HTMLImageElement = new Image();
|
|
900
|
-
imageObj.crossOrigin = 'anonymous';
|
|
901
|
-
imageObj.src = imageSrc;
|
|
902
|
-
imageObj.onload = () => {
|
|
903
|
-
proxy.canvasContext.globalCompositeOperation = 'source-over';
|
|
904
|
-
proxy.canvasContext.drawImage(imageObj, 0, 0, proxy.element.width, proxy.element.height);
|
|
905
|
-
const dataURL: string = proxy.canvasContext.canvas.toDataURL('image/jpeg');
|
|
906
|
-
proxy.download(proxy.getBlob(dataURL), fileName + '.' + 'jpeg');
|
|
907
|
-
proxy.canvasContext.clearRect( 0, 0, proxy.canvasContext.canvas.width, proxy.canvasContext.canvas.height);
|
|
908
|
-
this.resizeHandler();
|
|
909
|
-
};
|
|
910
|
-
this.snapColl.pop();
|
|
911
|
-
this.incStep--;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
private toSVG(fileName?: string, dataUrl?: string): string {
|
|
915
|
-
const svg: SVGSVGElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
916
|
-
svg.setAttribute('width', this.canvasContext.canvas.width.toString());
|
|
917
|
-
svg.setAttribute('height', this.canvasContext.canvas.height.toString());
|
|
918
|
-
const XLinkNS: string = 'http://www.w3.org/1999/xlink';
|
|
919
|
-
const img: SVGImageElement = document.createElementNS('http://www.w3.org/2000/svg', 'image');
|
|
920
|
-
img.setAttributeNS(null, 'height', this.canvasContext.canvas.height.toString());
|
|
921
|
-
img.setAttributeNS(null, 'width', this.canvasContext.canvas.width.toString());
|
|
922
|
-
img.setAttributeNS(XLinkNS, 'xlink:href', dataUrl);
|
|
923
|
-
svg.appendChild(img);
|
|
924
|
-
const prefix: string = 'data:image/svg+xml;base64,';
|
|
925
|
-
const header: string = '<svg' + ' xmlns="http://www.w3.org/2000/svg"' + ' xmlns:xlink="http://www.w3.org/1999/xlink"'
|
|
926
|
-
+ ` width="${this.canvasContext.canvas.width}"` + ` height="${this.canvasContext.canvas.height}"` + '>';
|
|
927
|
-
const footer: string = '</svg>';
|
|
928
|
-
const body: string = svg.innerHTML;
|
|
929
|
-
const data: string = header + body + footer;
|
|
930
|
-
const svgDataUrl: string = prefix + btoa(data);
|
|
931
|
-
if (fileName == null) {
|
|
932
|
-
return svgDataUrl;
|
|
933
|
-
} else {
|
|
934
|
-
this.download(this.getBlob(svgDataUrl), fileName + '.' + 'svg');
|
|
935
|
-
return null;
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
* To save the signature as Blob.
|
|
941
|
-
*
|
|
942
|
-
* @returns {Blob}.
|
|
943
|
-
*/
|
|
944
|
-
public saveAsBlob(): Blob {
|
|
945
|
-
return this.getBlob(this.canvasContext.canvas.toDataURL('image/png'));
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
/**
|
|
949
|
-
* Gets the signature as a Base 64 string.
|
|
950
|
-
*
|
|
951
|
-
* This method is used to retrieve the current signature on the canvas as a Base 64-encoded string, in the specified image format.
|
|
952
|
-
*
|
|
953
|
-
* @param {SignatureFileType} [type] - Specifies the type of the image format.
|
|
954
|
-
* Can be one of 'Png', 'Jpeg', or 'Svg'. If not specified, the default is 'Png'.
|
|
955
|
-
* @returns {string} - Returns the Base 64 string of the signature in the specified format.
|
|
956
|
-
*/
|
|
957
|
-
|
|
958
|
-
public getSignature(type?: SignatureFileType): string {
|
|
959
|
-
if (this.saveWithBackground && this.backgroundColor && !this.backgroundImage) {
|
|
960
|
-
this.tempContext.fillStyle = this.backgroundColor;
|
|
961
|
-
this.tempContext.fillRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
962
|
-
} else if (!this.backgroundColor && !this.backgroundImage && type === 'Jpeg') {
|
|
963
|
-
this.tempContext.fillStyle = '#fff';
|
|
964
|
-
this.tempContext.fillRect(0, 0, this.canvasContext.canvas.width, this.canvasContext.canvas.height);
|
|
965
|
-
}
|
|
966
|
-
this.tempContext.drawImage(this.element, 0, 0);
|
|
967
|
-
if (type === 'Jpeg') {
|
|
968
|
-
return this.tempCanvas.toDataURL('image/jpeg');
|
|
969
|
-
} else if (type === 'Svg') {
|
|
970
|
-
return this.toSVG(null, this.tempCanvas.toDataURL('image/png'));
|
|
971
|
-
}else {
|
|
972
|
-
return this.tempCanvas.toDataURL('image/png');
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* Get component name.
|
|
978
|
-
*
|
|
979
|
-
* @returns {string} - Module Name
|
|
980
|
-
* @private
|
|
981
|
-
*/
|
|
982
|
-
protected getModuleName(): string {
|
|
983
|
-
return 'signature';
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
/**
|
|
987
|
-
* To get the properties to be maintained in the persisted state.
|
|
988
|
-
*
|
|
989
|
-
* @returns {string} - Persist data
|
|
990
|
-
*/
|
|
991
|
-
protected getPersistData(): string {
|
|
992
|
-
this.signatureValue = this.snapColl[this.incStep];
|
|
993
|
-
return this.addOnPersist(['signatureValue']);
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
/**
|
|
997
|
-
* Removes the component from the DOM and detaches all its related event handlers.
|
|
998
|
-
* Also it maintains the initial input element from the DOM.
|
|
999
|
-
*
|
|
1000
|
-
* @method destroy
|
|
1001
|
-
* @returns {void}
|
|
1002
|
-
*/
|
|
1003
|
-
public destroy(): void {
|
|
1004
|
-
if (this.getModuleName() !== 'image-editor') {
|
|
1005
|
-
this.unwireEvents(null);
|
|
1006
|
-
removeClass([this.element], 'e-' + this.getModuleName());
|
|
1007
|
-
this.element.removeAttribute('tabindex');
|
|
1008
|
-
this.pointColl = null;
|
|
1009
|
-
this.tempContext = null;
|
|
1010
|
-
this.tempCanvas = null;
|
|
1011
|
-
this.canvasContext = null;
|
|
1012
|
-
}
|
|
1013
|
-
super.destroy();
|
|
1014
|
-
this.element = null;
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
/**
|
|
1018
|
-
* Modified onPropertyChanged method for both blazor and EJ2 signature component.
|
|
1019
|
-
*
|
|
1020
|
-
* @private
|
|
1021
|
-
* @param {string} key - Specifies the property, which changed.
|
|
1022
|
-
* @param {string} value - Specifies the property value changed.
|
|
1023
|
-
* @returns {void}
|
|
1024
|
-
*/
|
|
1025
|
-
public propertyChanged(key: string, value: string | boolean | number): void {
|
|
1026
|
-
const canvasNew: CanvasRenderingContext2D = this.canvasContext;
|
|
1027
|
-
switch (key) {
|
|
1028
|
-
case 'backgroundColor':
|
|
1029
|
-
canvasNew.canvas.style.backgroundColor = value as string;
|
|
1030
|
-
this.backgroundColor = value as string;
|
|
1031
|
-
break;
|
|
1032
|
-
case 'backgroundImage':
|
|
1033
|
-
canvasNew.canvas.style.backgroundImage = 'url(' + value + ')';
|
|
1034
|
-
this.backgroundImage = value as string;
|
|
1035
|
-
if (this.saveWithBackground) {
|
|
1036
|
-
this.setBackgroundImage(this.backgroundImage, 'temp');
|
|
1037
|
-
}
|
|
1038
|
-
break;
|
|
1039
|
-
case 'strokeColor':
|
|
1040
|
-
canvasNew.fillStyle = value as string;
|
|
1041
|
-
this.strokeColor = value as string;
|
|
1042
|
-
break;
|
|
1043
|
-
case 'saveWithBackground':
|
|
1044
|
-
this.saveWithBackground = value as boolean;
|
|
1045
|
-
break;
|
|
1046
|
-
case 'maxStrokeWidth':
|
|
1047
|
-
this.maxStrokeWidth = value as number;
|
|
1048
|
-
break;
|
|
1049
|
-
case 'minStrokeWidth':
|
|
1050
|
-
this.minStrokeWidth = value as number;
|
|
1051
|
-
break;
|
|
1052
|
-
case 'velocity':
|
|
1053
|
-
this.velocity = value as number;
|
|
1054
|
-
break;
|
|
1055
|
-
case 'isReadOnly':
|
|
1056
|
-
this.isRead(value as boolean);
|
|
1057
|
-
break;
|
|
1058
|
-
case 'disabled':
|
|
1059
|
-
this.enableOrDisable(value as boolean);
|
|
1060
|
-
break;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
/**
|
|
1066
|
-
* Interface for Point object.
|
|
1067
|
-
*/
|
|
1068
|
-
interface Point {
|
|
1069
|
-
/**
|
|
1070
|
-
* Gets or sets the x position of the point.
|
|
1071
|
-
*/
|
|
1072
|
-
x: number;
|
|
1073
|
-
/**
|
|
1074
|
-
* Gets or sets the y position of the point.
|
|
1075
|
-
*/
|
|
1076
|
-
y: number;
|
|
1077
|
-
/**
|
|
1078
|
-
* Gets or sets the time.
|
|
1079
|
-
*/
|
|
1080
|
-
time?: number;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
/**
|
|
1084
|
-
* Defines the signature file type.
|
|
1085
|
-
*/
|
|
1086
|
-
export type SignatureFileType = 'Png' | 'Jpeg' | 'Svg' ;
|
|
1087
|
-
|
|
1088
|
-
/**
|
|
1089
|
-
* Interface for before save the canvas as image.
|
|
1090
|
-
*/
|
|
1091
|
-
export interface SignatureBeforeSaveEventArgs {
|
|
1092
|
-
/**
|
|
1093
|
-
* Gets or sets whether to cancel the save action. You can cancel and perform save operation programmatically.
|
|
1094
|
-
*/
|
|
1095
|
-
cancel?: boolean;
|
|
1096
|
-
/**
|
|
1097
|
-
* Gets or sets the file name to be saved.
|
|
1098
|
-
*/
|
|
1099
|
-
fileName?: string;
|
|
1100
|
-
/**
|
|
1101
|
-
* Gets or sets the file type to be saved.
|
|
1102
|
-
*/
|
|
1103
|
-
type?: SignatureFileType;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* Interface for changes occur in the signature.
|
|
1108
|
-
*/
|
|
1109
|
-
export interface SignatureChangeEventArgs {
|
|
1110
|
-
/**
|
|
1111
|
-
* Gets or sets the action name of the signature.
|
|
1112
|
-
*/
|
|
1113
|
-
actionName: string;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* Interface for Dimension calculation in the imageEditor.
|
|
1118
|
-
*/
|
|
1119
|
-
export interface Dimension {
|
|
1120
|
-
/**
|
|
1121
|
-
* Gets x position from the canvas.
|
|
1122
|
-
*/
|
|
1123
|
-
x?: number;
|
|
1124
|
-
/**
|
|
1125
|
-
* Gets y position from the canvas.
|
|
1126
|
-
*/
|
|
1127
|
-
y?: number;
|
|
1128
|
-
/**
|
|
1129
|
-
* Gets width of the image.
|
|
1130
|
-
*/
|
|
1131
|
-
width: number;
|
|
1132
|
-
/**
|
|
1133
|
-
* Gets height of the image.
|
|
1134
|
-
*/
|
|
1135
|
-
height: number;
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
/**
|
|
1139
|
-
* Interface for active object in the imageEditor.
|
|
1140
|
-
*/
|
|
1141
|
-
export interface ActivePoint {
|
|
1142
|
-
/**
|
|
1143
|
-
* Gets mouse down x-point.
|
|
1144
|
-
*/
|
|
1145
|
-
startX: number;
|
|
1146
|
-
/**
|
|
1147
|
-
* Gets mouse down y-point.
|
|
1148
|
-
*/
|
|
1149
|
-
startY: number;
|
|
1150
|
-
/**
|
|
1151
|
-
* Gets mouse move x-point.
|
|
1152
|
-
*/
|
|
1153
|
-
endX?: number;
|
|
1154
|
-
/**
|
|
1155
|
-
* Gets mouse move y-point.
|
|
1156
|
-
*/
|
|
1157
|
-
endY?: number;
|
|
1158
|
-
/**
|
|
1159
|
-
* Gets width of the selection.
|
|
1160
|
-
*/
|
|
1161
|
-
width?: number;
|
|
1162
|
-
/**
|
|
1163
|
-
* Gets height of the selection.
|
|
1164
|
-
*/
|
|
1165
|
-
height?: number;
|
|
1166
|
-
/**
|
|
1167
|
-
* Gets radius of the circle dot.
|
|
1168
|
-
*/
|
|
1169
|
-
radius?: number;
|
|
1170
|
-
}
|