Переглянути джерело

fixed if statement and possible issue with animationName failing when idx == 0

Adam Bowman 8 роки тому
батько
коміт
f571983071
1 змінених файлів з 18 додано та 18 видалено
  1. 18 18
      src/Animations/babylon.animatable.ts

+ 18 - 18
src/Animations/babylon.animatable.ts

@@ -101,14 +101,14 @@
         public stop(animationName?: string): void {
             
             if (animationName) {
-                
+
                 var idx = this._scene._activeAnimatables.indexOf(this);
-                
-                if (idx) {
+
+                if (idx > -1) {
 
                     var animations = this._animations;
                     var numberOfAnimationsStopped = 0;
-
+                    
                     for (var index = animations.length - 1; index >= 0; index--) {
                         if (typeof animationName === "string" && animations[index].name != animationName) {
                             continue;
@@ -121,30 +121,30 @@
 
                     if (animations.length == numberOfAnimationsStopped) {
                         this._scene._activeAnimatables.splice(idx, 1);
-                        
+
                         if (this.onAnimationEnd) {
                             this.onAnimationEnd();
                         }
                     }
+                }
 
-                } else {
-
-                    var index = this._scene._activeAnimatables.indexOf(this);
+            } else {
 
-                    if (index > -1) {
-                        this._scene._activeAnimatables.splice(index, 1);
-                        var animations = this._animations;
-                        
-                        for (var index = 0; index < animations.length; index++) {
-                            animations[index].reset();
-                        }
+                var index = this._scene._activeAnimatables.indexOf(this);
 
-                        if (this.onAnimationEnd) {
-                            this.onAnimationEnd();
-                        }
+                if (index > -1) {
+                    this._scene._activeAnimatables.splice(index, 1);
+                    var animations = this._animations;
+                    
+                    for (var index = 0; index < animations.length; index++) {
+                        animations[index].reset();
                     }
                     
+                    if (this.onAnimationEnd) {
+                        this.onAnimationEnd();
+                    }
                 }
+
             }
         }