Skip to content

Commit

Permalink
feat: add back top btn
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangJun2019 committed Oct 15, 2023
1 parent 91faeb3 commit 5246ee1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions components/Post/PostBackTop.client.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup lang="ts">
import { useWindowScroll } from '@vueuse/core'
const show = computed(() => {
const { y } = useWindowScroll()
return y.value >= 300
})
function goTop() {
window.scrollTo({
top: 0,
behavior: 'smooth',
})
}
</script>

<template>
<div :class="show ? 'opacity-90' : 'opacity-0'" class="fixed right-6 bottom-4 transition-all duration-400 ease-in-out" @click.top="goTop()">
<UButton icon="i-heroicons-arrow-up-circle" variant="ghost" />
</div>
</template>
1 change: 1 addition & 0 deletions layouts/content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</UButton>
</main>
<Footer />
<PostBackTop />
</main>
</AppLayout>
</template>
Expand Down

0 comments on commit 5246ee1

Please sign in to comment.