|
@@ -138,20 +138,32 @@ function GoodsInfo({ isOpen, id, closePage }: Props) {
|
|
const endNum = -window.innerWidth - width - 200;
|
|
const endNum = -window.innerWidth - width - 200;
|
|
barrMoveRefKill.current?.kill();
|
|
barrMoveRefKill.current?.kill();
|
|
// 开始动画
|
|
// 开始动画
|
|
- barrMoveRefKill.current = gsap.fromTo(
|
|
|
|
- barrMoveRef.current,
|
|
|
|
- { x: 0 },
|
|
|
|
- {
|
|
|
|
|
|
+
|
|
|
|
+ // 总弹幕数量只有 1 的情况
|
|
|
|
+ if (barrageAll.length === 1) {
|
|
|
|
+ barrMoveRefKill.current = gsap.to(barrMoveRef.current, {
|
|
duration: 16,
|
|
duration: 16,
|
|
ease: "none",
|
|
ease: "none",
|
|
x: endNum,
|
|
x: endNum,
|
|
- onComplete: () => {
|
|
|
|
- let num = barrInd + 1;
|
|
|
|
- if (num >= barrageAll.length) num = 0;
|
|
|
|
- setBarrInd(num);
|
|
|
|
- },
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ repeat: -1,
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ // 有超过 1 的情况
|
|
|
|
+ barrMoveRefKill.current = gsap.fromTo(
|
|
|
|
+ barrMoveRef.current,
|
|
|
|
+ { x: 0 },
|
|
|
|
+ {
|
|
|
|
+ duration: 16,
|
|
|
|
+ ease: "none",
|
|
|
|
+ x: endNum,
|
|
|
|
+ onComplete: () => {
|
|
|
|
+ let num = barrInd + 1;
|
|
|
|
+ if (num >= barrageAll.length) num = 0;
|
|
|
|
+ setBarrInd(num);
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}, 200);
|
|
}, 200);
|
|
}, [barrInd, barrageAll.length]);
|
|
}, [barrInd, barrageAll.length]);
|
|
@@ -420,7 +432,7 @@ function GoodsInfo({ isOpen, id, closePage }: Props) {
|
|
<h3>{barrageAll[barrInd].name}</h3>
|
|
<h3>{barrageAll[barrInd].name}</h3>
|
|
<p>
|
|
<p>
|
|
{barrageAll[barrInd].authorName}
|
|
{barrageAll[barrInd].authorName}
|
|
- {barrageAll[barrInd].updateTime}
|
|
|
|
|
|
+ {barrageAll[barrInd].createTime}
|
|
观 [{barrageAll[barrInd].goodsName}] 有感
|
|
观 [{barrageAll[barrInd].goodsName}] 有感
|
|
</p>
|
|
</p>
|
|
</div>
|
|
</div>
|