Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Poe): add animation when component is visible #132

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions components/custom/Poe.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<script setup lang="ts">
import { useElementVisibility } from '@vueuse/core'

const elePoe = ref<HTMLElement | null>(null)
const targetIsVisible = useElementVisibility(elePoe)
</script>

<template>
<div class="body pt-12 h-screen pb-12">
<div class="relative flex flex-row items-center justify-center gap-2 h-full">
<div
ref="elePoe"
class="body pt-12 h-screen pb-12"
>
<div
:class="{ animate: targetIsVisible }"
class="relative flex flex-row items-center justify-center gap-2 h-full"
>
<div class="major text-7xl text-center font-bold tracking-tight text-black">
谁怕?一蓑烟雨任平生
</div>
Expand Down Expand Up @@ -32,6 +41,7 @@
.major {
@apply opacity-0;
animation: fadeIn 1.5s ease-in-out 3.5s forwards;
animation-play-state: paused !important;
}

.poe {
Expand All @@ -40,10 +50,15 @@

.poe div {
@apply block m-3 z-10 opacity-20 hover:opacity-100 duration-200;
animation-fill-mode: forwards;
animation-play-state: paused !important;
white-space: nowrap;
}

.animate .major,
.animate .poe div {
animation-play-state: running !important;
}

@keyframes fadeIn {
0% {
opacity: 0;
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default defineNuxtConfig({
'@nuxtjs/web-vitals',
'nuxt-gtag',
'@nuxt/eslint',
'@vueuse/nuxt',
],

eslint: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"@vitest/coverage-v8": "^1.4.0",
"@vueuse/nuxt": "^10.9.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"consola": "^3.2.3",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading