diff options
| author | Stanisław Zagórowski <hasohasacz@gmail.com> | 2023-10-09 12:32:49 +0200 |
|---|---|---|
| committer | Stanisław Zagórowski <hasohasacz@gmail.com> | 2023-10-09 12:32:49 +0200 |
| commit | 4d26a164a9340276c2923543a88d6d180326d0de (patch) | |
| tree | 8c2993561a694e9c63a6fb81b3150c5a08b64195 /front | |
| parent | c49d6722d80e9f273724f10894201e4e185a6c0a (diff) | |
front: add webgl check
Diffstat (limited to 'front')
| -rw-r--r-- | front/src/components/animated_bg.tsx | 14 |
1 files changed, 13 insertions, 1 deletions
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 }) : () => <div />; |
