style(CourseDetailPage): 为收藏按钮添加动画效果和过渡样式
为收藏按钮添加了动画效果和过渡样式,提升用户体验。动画在用户点击收藏时触发,按钮会有一个缩放效果,同时添加了过渡样式使变化更加平滑。
Showing
1 changed file
with
20 additions
and
2 deletions
| ... | @@ -219,10 +219,10 @@ | ... | @@ -219,10 +219,10 @@ |
| 219 | </svg> | 219 | </svg> |
| 220 | 分享 | 220 | 分享 |
| 221 | </button> --> | 221 | </button> --> |
| 222 | - <button class="flex flex-col items-center text-gray-500 text-xs" @click="toggleFavorite"> | 222 | + <button class="flex flex-col items-center text-gray-500 text-xs transition-transform duration-300" @click="toggleFavorite" :class="{ 'animate-favorite': isFavorite }"> |
| 223 | <svg | 223 | <svg |
| 224 | xmlns="http://www.w3.org/2000/svg" | 224 | xmlns="http://www.w3.org/2000/svg" |
| 225 | - class="h-6 w-6" | 225 | + class="h-6 w-6 transition-transform duration-300" |
| 226 | :fill="isFavorite ? 'red' : 'none'" | 226 | :fill="isFavorite ? 'red' : 'none'" |
| 227 | viewBox="0 0 24 24" | 227 | viewBox="0 0 24 24" |
| 228 | :stroke="isFavorite ? 'red' : 'currentColor'" | 228 | :stroke="isFavorite ? 'red' : 'currentColor'" |
| ... | @@ -345,3 +345,21 @@ onMounted(() => { | ... | @@ -345,3 +345,21 @@ onMounted(() => { |
| 345 | } | 345 | } |
| 346 | }) | 346 | }) |
| 347 | </script> | 347 | </script> |
| 348 | + | ||
| 349 | +<style scoped> | ||
| 350 | +.animate-favorite { | ||
| 351 | + animation: favorite-animation 0.5s ease; | ||
| 352 | +} | ||
| 353 | + | ||
| 354 | +@keyframes favorite-animation { | ||
| 355 | + 0% { | ||
| 356 | + transform: scale(1); | ||
| 357 | + } | ||
| 358 | + 50% { | ||
| 359 | + transform: scale(1.3); | ||
| 360 | + } | ||
| 361 | + 100% { | ||
| 362 | + transform: scale(1); | ||
| 363 | + } | ||
| 364 | +} | ||
| 365 | +</style> | ... | ... |
-
Please register or login to post a comment