Browse Source

Checking if functions are undefined

Now checking if these functions are defined before firing them.
Jordan Kintzle 4 years ago
parent
commit
837f3ef258
1 changed files with 6 additions and 2 deletions
  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();