Ver código fonte

Checking if functions are undefined

Now checking if these functions are defined before firing them.
Jordan Kintzle 4 anos atrás
pai
commit
837f3ef258
1 arquivos alterados com 6 adições e 2 exclusões
  1. 6 2
      gui/src/2D/controls/toggleButton.ts

+ 6 - 2
gui/src/2D/controls/toggleButton.ts

@@ -109,9 +109,13 @@ export class ToggleButton extends Rectangle {
 
         // Update the visual state based on the new value
         if (this._isActive) {
-            this.toActiveAnimation();
+            if (this.toActiveAnimation) {
+                this.toActiveAnimation();
+            }
         } else {
-            this.toInactiveAnimation();
+            if (this.toInactiveAnimation) {
+                this.toInactiveAnimation?.();
+            }
         }
 
         this._markAsDirty();