动效移动端特殊处理

This commit is contained in:
tangly1024.com
2024-06-03 18:02:09 +08:00
parent b22a53c6a3
commit 1f5b77406a
2 changed files with 24 additions and 2 deletions

View File

@@ -35,7 +35,11 @@ const Fireworks = () => {
loadFireworks()
return () => {
// 在组件卸载时清理资源(如果需要)
// 在组件卸载时清理资源
const fireworksElements = document.getElementsByClassName('fireworks')
while (fireworksElements.length > 0) {
fireworksElements[0].parentNode.removeChild(fireworksElements[0])
}
}
}, [])

View File

@@ -15,8 +15,26 @@ const MOUSE_FOLLOW = () => {
loadExternalResource('/js/mouse-follow.js', 'js').then(url => {
window.createMouseCanvas && window.createMouseCanvas()({ type, color })
})
return () => {
// 在组件卸载时清理资源
const mouseFollowElement = document.getElementById('vixcityCanvas')
mouseFollowElement?.parentNode?.removeChild(mouseFollowElement)
}
}, [])
return <></>
return (
<>
<style global jsx>
{`
@media (max-width: 600px) {
#vixcityCanvas {
display: none;
}
}
`}
</style>
</>
)
}
export default MOUSE_FOLLOW