Merge pull request #1384 from Reggino/allow-typed-points-array

Allow line points to be of type TypedArray.
This commit is contained in:
Anton Lavrenov 2022-08-08 09:42:55 -05:00 committed by GitHub
commit baf8780b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -142,6 +142,12 @@ export function getFunctionValidator() {
export function getNumberArrayValidator() {
if (Konva.isUnminified) {
return function (val: any, attr: string) {
// Retrieve TypedArray constructor as found in MDN (if TypedArray is available)
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
if (TypedArray && val instanceof TypedArray) {
return val
}
if (!Util._isArray(val)) {
Util.warn(
_formatValue(val) +

View File

@ -51,7 +51,7 @@ function expandPoints(p, tension) {
}
export interface LineConfig extends ShapeConfig {
points?: number[];
points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
tension?: number;
closed?: boolean;
bezier?: boolean;