From 3714d5ee4ab4305dcc3690bc1c3fa39c6bf5c6bd Mon Sep 17 00:00:00 2001 From: ZhangXianQiang <1135831638@qq.com> Date: 星期五, 19 四月 2024 15:17:51 +0800 Subject: [PATCH] feat:添加资源销毁,防止内存泄漏 --- src/views/screen/components/screen-map-three/experience/utils/time.js | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/views/screen/components/screen-map-three/experience/utils/time.js b/src/views/screen/components/screen-map-three/experience/utils/time.js index 680b19d..e60078b 100644 --- a/src/views/screen/components/screen-map-three/experience/utils/time.js +++ b/src/views/screen/components/screen-map-three/experience/utils/time.js @@ -6,6 +6,7 @@ this.current = this.start; this.elapsed = 0; this.delta = 16; + // 鍚堥�傜殑鏃舵満鎵цloop寰幆 window.requestAnimationFrame(() => { this.tick(); }); @@ -17,9 +18,14 @@ this.current = currentTime; this.elapsed = this.current - this.start; this.trigger('tick'); - - window.requestAnimationFrame(() => { + + this.loopId = window.requestAnimationFrame(() => { this.tick(); }); } + + destroy() { + window.cancelAnimationFrame(this.loopId); + this.off('tick'); + } } \ No newline at end of file -- Gitblit v1.8.0