diff --git a/src/index.tsx b/src/index.tsx index 6ff063a..61be18b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -137,20 +137,25 @@ function validateOptions(input?: CaptureOptions): { const errors: string[] = []; if ( "width" in options && - (typeof options.width !== "number" || options.width <= 0) + (typeof options.width !== "number" || + !Number.isFinite(options.width) || + options.width <= 0) ) { errors.push("option width should be a positive number"); delete options.width; } if ( "height" in options && - (typeof options.height !== "number" || options.height <= 0) + (typeof options.height !== "number" || + !Number.isFinite(options.height) || + options.height <= 0) ) { errors.push("option height should be a positive number"); delete options.height; } if ( typeof options.quality !== "number" || + !Number.isFinite(options.quality) || options.quality < 0 || options.quality > 1 ) { @@ -159,9 +164,12 @@ function validateOptions(input?: CaptureOptions): { } if (typeof options.snapshotContentContainer !== "boolean") { errors.push("option snapshotContentContainer should be a boolean"); + options.snapshotContentContainer = defaultOptions.snapshotContentContainer; } if (typeof options.handleGLSurfaceViewOnAndroid !== "boolean") { errors.push("option handleGLSurfaceViewOnAndroid should be a boolean"); + options.handleGLSurfaceViewOnAndroid = + defaultOptions.handleGLSurfaceViewOnAndroid; } if (acceptedFormats.indexOf(options.format || "") === -1) { const badFormat = options.format;