|
|
@@ -15,6 +15,9 @@ type Props = {
|
|
|
}
|
|
|
|
|
|
function Zloding({ isShow, bacNum, callBackFu }: Props) {
|
|
|
+ // 增加消失的时候透明度
|
|
|
+ const [flag, setFlag] = useState(false)
|
|
|
+
|
|
|
const [showFlag, setShowFlag] = useState(false)
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -29,18 +32,26 @@ function Zloding({ isShow, bacNum, callBackFu }: Props) {
|
|
|
const [loding, setLoding] = useState(0)
|
|
|
const lodingRef = useRef(0)
|
|
|
|
|
|
+ const timeRef = useRef(-1)
|
|
|
+
|
|
|
+ const flagRef = useRef(true)
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (showFlag) {
|
|
|
window.unityLoading = (progress: number) => {
|
|
|
const num = Math.round(Number(progress * 100))
|
|
|
setLoding(num)
|
|
|
- if (num >= 100) {
|
|
|
- setShowFlag(false)
|
|
|
- if (callBackFu) callBackFu()
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
+ if (num >= 100 && flagRef.current) {
|
|
|
+ clearTimeout(timeRef.current)
|
|
|
+ setShowFlag(false)
|
|
|
+ setFlag(true)
|
|
|
+ timeRef.current = window.setTimeout(() => {
|
|
|
setLoding(0)
|
|
|
- }, 200)
|
|
|
+ setFlag(false)
|
|
|
+ }, 1000)
|
|
|
+ if (callBackFu) callBackFu()
|
|
|
+ flagRef.current = false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -53,7 +64,11 @@ function Zloding({ isShow, bacNum, callBackFu }: Props) {
|
|
|
return (
|
|
|
<div
|
|
|
id='Zloding'
|
|
|
- className={classNames(styles.Zloding, showFlag ? styles.ZlodingShow : '')}
|
|
|
+ className={classNames(
|
|
|
+ styles.Zloding,
|
|
|
+ showFlag ? styles.ZlodingShow : '',
|
|
|
+ flag && !showFlag ? styles.ZlodingChange : ''
|
|
|
+ )}
|
|
|
style={{ backgroundImage: `url(${bacImgRes})` }}
|
|
|
>
|
|
|
<div className='ZlodingBox'>
|