@@ -7,7 +7,7 @@ import PostList from '@/components/PostList';
7
7
import fetchPosts from '@/app/timeline/actions/fetchPosts' ;
8
8
import { useSession } from 'next-auth/react' ;
9
9
import { FaArrowUp } from 'react-icons/fa' ;
10
- import { motion } from 'framer-motion' ;
10
+ import { motion , AnimatePresence } from 'framer-motion' ;
11
11
12
12
// props の型定義
13
13
interface TimelineProps {
@@ -126,20 +126,23 @@ const Timeline = ({ limit, max, targetUserUrl, className }: TimelineProps) => {
126
126
{ hasMore && < p className = 'py-3 text-center' > 投稿を取得中...</ p > }
127
127
< div ref = { targetRef } className = 'h-px' />
128
128
{ ! hasMore && < p className = 'py-3 text-center' > これ以上投稿を取得できません。</ p > }
129
- { showTopButton && (
130
- < motion . div
131
- initial = { { opacity : 0 , x : '-50%' , y : - 10 } }
132
- animate = { { opacity : 1 , x : '-50%' , y : 0 } }
133
- transition = { { duration : 0.2 } }
134
- onClick = { ( ) => {
135
- window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
136
- } }
137
- className = 'fixed left-1/2 top-12 my-5 flex items-center justify-center rounded-xl bg-orange-400 px-3 hover:bg-orange-500'
138
- >
139
- < FaArrowUp color = 'white' />
140
- < a className = 'py-1 pl-1 text-white shadow-md hover:cursor-pointer' > 最新の短歌に戻る</ a >
141
- </ motion . div >
142
- ) }
129
+ < AnimatePresence mode = 'wait' >
130
+ { showTopButton && (
131
+ < motion . div
132
+ initial = { { opacity : 0 , x : '-50%' , y : - 10 } }
133
+ animate = { { opacity : 1 , x : '-50%' , y : 0 } }
134
+ exit = { { opacity : 0 , x : '-50%' , y : - 10 } }
135
+ transition = { { duration : 0.2 } }
136
+ onClick = { ( ) => {
137
+ window . scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
138
+ } }
139
+ className = 'fixed left-1/2 top-12 my-5 flex items-center justify-center rounded-xl bg-orange-400 px-3 hover:bg-orange-500'
140
+ >
141
+ < FaArrowUp color = 'white' />
142
+ < a className = 'py-1 pl-1 text-white shadow-md hover:cursor-pointer' > 最新の短歌に戻る</ a >
143
+ </ motion . div >
144
+ ) }
145
+ </ AnimatePresence >
143
146
</ div >
144
147
) ;
145
148
} ;
0 commit comments