From 4d26a164a9340276c2923543a88d6d180326d0de Mon Sep 17 00:00:00 2001 From: Stanisław Zagórowski Date: Mon, 9 Oct 2023 12:32:49 +0200 Subject: front: add webgl check --- front/src/components/animated_bg.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/front/src/components/animated_bg.tsx b/front/src/components/animated_bg.tsx index 6a8ab3a..80a8a63 100644 --- a/front/src/components/animated_bg.tsx +++ b/front/src/components/animated_bg.tsx @@ -111,4 +111,16 @@ const timeLoop = ( }; } -export const AnimatedBg = timeLoop(AnimatedBgInternal, { refreshRate: fps }); +const checkWebGL = () => { + try { + const canvas = document.createElement("canvas"); + return !!( + window.WebGLRenderingContext && + (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")) + ); + } catch (e) { + return false; + } +} + +export const AnimatedBg = checkWebGL() ? timeLoop(AnimatedBgInternal, { refreshRate: fps }) : () =>
; -- cgit v1.3.1