check for existing canvas

This commit is contained in:
MLH
2025-01-25 19:43:01 +01:00
parent 54dbf817aa
commit 7b4c6107cd
5 changed files with 127 additions and 102 deletions

View File

@@ -55,6 +55,11 @@ observer.observe(document.body, {
function initializeCanvas() {
if (document.getElementById('snowfallCanvas')) {
console.warn('Canvas bereits vorhanden.');
return;
}
const container = document.querySelector('.snowfall-container');
if (!container) {
console.error('Error: No element with class "snowfall-container" found.');
@@ -143,7 +148,7 @@ function animateSnowfall() {
// initialize snowfall
document.addEventListener('DOMContentLoaded', () => {
if (!snowfall){
if (!snowfall) {
console.warn('Snowfall is disabled.');
return; // exit if snowfall is disabled
}