diff --git a/src/Context.ts b/src/Context.ts index 3f693e8f..9ea014b9 100644 --- a/src/Context.ts +++ b/src/Context.ts @@ -108,13 +108,7 @@ export function isCSSFiltersSupported(): boolean { _cssFiltersSupported = false; return false; } - - // Test if setting the filter property works - const originalFilter = ctx.filter; - ctx.filter = 'blur(1px)'; - _cssFiltersSupported = ctx.filter === 'blur(1px)'; - ctx.filter = originalFilter; - return _cssFiltersSupported; + return !!ctx && 'filter' in ctx; } catch (e) { _cssFiltersSupported = false; return false; diff --git a/src/Node.ts b/src/Node.ts index 1bedeb3e..61e846e4 100644 --- a/src/Node.ts +++ b/src/Node.ts @@ -44,7 +44,9 @@ function parseCSSFilters(cssFilter: string): FilterFunction { } case 'brightness': { - const brightness = parseFloat(filterValue); + const brightness = filterValue.includes('%') + ? parseFloat(filterValue) / 100 + : parseFloat(filterValue); return function (imageData) { (this as any).brightness(brightness); // CSS uses multiplier const KonvaFilters = (Konva as any).Filters; @@ -694,9 +696,9 @@ export abstract class Node { const fallbackRequired = typeof filters[i] === 'string' && !isCSSFiltersSupported(); if (fallbackRequired) { - Util.warn( - `CSS filter "${filters[i]}" is not supported in native mode.` - ); + // Util.warn( + // `CSS filter "${filters[i]}" is not supported in native mode.` + // ); } if (typeof filters[i] !== 'string' || !isCSSFiltersSupported()) { useNativeOnly = false;