Jelajahi Sumber

Renderers: Make animation modules more robust. (#33159)

Michael Herzog 1 bulan lalu
induk
melakukan
79af681317

+ 1 - 1
src/renderers/common/Animation.js

@@ -95,7 +95,7 @@ class Animation {
 	 */
 	stop() {
 
-		this._context.cancelAnimationFrame( this._requestId );
+		if ( this._context !== null ) this._context.cancelAnimationFrame( this._requestId );
 
 		this._requestId = null;
 

+ 2 - 1
src/renderers/webgl/WebGLAnimation.js

@@ -19,6 +19,7 @@ function WebGLAnimation() {
 
 			if ( isAnimating === true ) return;
 			if ( animationLoop === null ) return;
+			if ( context === null ) return;
 
 			requestId = context.requestAnimationFrame( onAnimationFrame );
 
@@ -28,7 +29,7 @@ function WebGLAnimation() {
 
 		stop: function () {
 
-			context.cancelAnimationFrame( requestId );
+			if ( context !== null ) context.cancelAnimationFrame( requestId );
 
 			isAnimating = false;
 

粤ICP备19079148号