소스 검색

Checking if functions are undefined

Now checking if these functions are defined before firing them.
Jordan Kintzle 4 년 전
부모
커밋
837f3ef258
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  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();