Explorar o código

Checking if functions are undefined

Now checking if these functions are defined before firing them.
Jordan Kintzle %!s(int64=4) %!d(string=hai) anos
pai
achega
837f3ef258
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  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();