From d9d7839e7d525937bc3471385fbf1eb513caf8a6 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 13 May 2022 15:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E5=8A=A0=E8=BD=BD=E6=8C=82?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Live2D.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/Live2D.js b/components/Live2D.js index e91a3806..c763349a 100644 --- a/components/Live2D.js +++ b/components/Live2D.js @@ -17,7 +17,10 @@ export default function Live2D() { } useEffect(() => { - initLive2D() + window.addEventListener('scroll', initLive2D) + return () => { + window.removeEventListener('scroll', initLive2D) + } }, []) return @@ -27,6 +30,7 @@ export default function Live2D() { * 加载宠物 */ function initLive2D() { + window.removeEventListener('scroll', initLive2D) setTimeout(() => { // 加载 waifu.css live2d.min.js waifu-tips.js if (screen.width >= 768) { @@ -38,5 +42,5 @@ function initLive2D() { loadlive2d('live2d', BLOG.WIDGET_PET_LINK) }) } - }, 1000) + }, 300) }