File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,12 +188,16 @@ const PeriodicalIndexPage: NextPage = () => {
188188
189189 const [ bullets , setBullets ] = useState < BulletItem [ ] > ( [ ] ) ;
190190 const [ isDanmakuPaused , setIsDanmakuPaused ] = useState ( false ) ;
191+ const [ danmakuKey , setDanmakuKey ] = useState ( 0 ) ;
191192
192193 useEffect ( ( ) => {
193194 const num = currentIndex === 0 ? undefined : currentVolume ;
194195 if ( currentIndex === 0 || currentVolume > 0 ) {
195196 getVolumeBullets ( num ) . then ( ( res ) => {
196- setBullets ( res . success ? res . data : [ ] ) ;
197+ if ( res . success && res . data . length > 0 ) {
198+ setBullets ( res . data ) ;
199+ setDanmakuKey ( ( prev ) => prev + 1 ) ;
200+ }
197201 } ) ;
198202 }
199203 } , [ currentVolume , currentIndex ] ) ;
@@ -255,7 +259,10 @@ const PeriodicalIndexPage: NextPage = () => {
255259 < div className = 'pointer-events-none absolute inset-0 bg-gradient-to-b from-white/90 via-white/60 to-white/90 dark:from-gray-800/90 dark:via-gray-800/60 dark:to-gray-800/90' />
256260
257261 { bullets . length > 0 && (
258- < div className = 'danmaku-container absolute inset-x-0 top-6 z-[5] h-48 overflow-hidden md:h-52' >
262+ < div
263+ key = { danmakuKey }
264+ className = 'danmaku-container absolute inset-x-0 top-6 z-[5] h-48 overflow-hidden md:h-52'
265+ >
259266 { DANMAKU_ROWS . map ( ( config , idx ) => (
260267 < DanmakuRow
261268 key = { idx }
Original file line number Diff line number Diff line change @@ -325,3 +325,16 @@ code::after {
325325 transform : translateX (0 );
326326 }
327327}
328+
329+ @keyframes danmaku-fade-in {
330+ 0% {
331+ opacity : 0 ;
332+ }
333+ 100% {
334+ opacity : 1 ;
335+ }
336+ }
337+
338+ .danmaku-container {
339+ animation : danmaku-fade-in 0.5s ease-out;
340+ }
You can’t perform that action at this time.
0 commit comments