tsparticles 1.37.3 → 1.37.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tsparticles.js CHANGED
@@ -2163,6 +2163,7 @@
2163
2163
  this.mouseDownHandler = () => this.mouseDown();
2164
2164
  this.visibilityChangeHandler = () => this.handleVisibilityChange();
2165
2165
  this.themeChangeHandler = e => this.handleThemeChange(e);
2166
+ this.oldThemeChangeHandler = e => this.handleThemeChange(e);
2166
2167
  this.resizeHandler = () => this.handleWindowResize();
2167
2168
  }
2168
2169
  addListeners() {
@@ -2186,9 +2187,17 @@
2186
2187
  } else {
2187
2188
  container.interactivity.element = container.canvas.element;
2188
2189
  }
2189
- const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
2190
+ const mediaMatch = !isSsr() && typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
2190
2191
  if (mediaMatch) {
2191
- manageListener(mediaMatch, "change", this.themeChangeHandler, add);
2192
+ if (mediaMatch.addEventListener !== undefined) {
2193
+ manageListener(mediaMatch, "change", this.themeChangeHandler, add);
2194
+ } else if (mediaMatch.addListener !== undefined) {
2195
+ if (add) {
2196
+ mediaMatch.addListener(this.oldThemeChangeHandler);
2197
+ } else {
2198
+ mediaMatch.removeListener(this.oldThemeChangeHandler);
2199
+ }
2200
+ }
2192
2201
  }
2193
2202
  const interactivityEl = container.interactivity.element;
2194
2203
  if (!interactivityEl) {