BackToTheTop.vue 905 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div class="pageTop" v-intersect="onTopIntersect"/>
  3. <v-btn
  4. v-if="isVisible"
  5. :to="{ path: '', hash: '#top' }"
  6. aria-label="Back to the top of the page"
  7. class="back-to-the-top"
  8. >
  9. <v-icon>fas fa-arrow-up</v-icon>
  10. </v-btn>
  11. </template>
  12. <script setup lang="ts">
  13. const isVisible: Ref<boolean> = ref(false)
  14. const onTopIntersect = (intersect: boolean) => {
  15. isVisible.value = !intersect
  16. }
  17. </script>
  18. <style scoped lang="scss">
  19. .pageTop {
  20. position: absolute;
  21. top: 0;
  22. height: 300px;
  23. width: 0;
  24. }
  25. .back-to-the-top {
  26. position: fixed;
  27. right: 5%;
  28. bottom: 58px;
  29. z-index: 100;
  30. height: 48px !important;
  31. width: 48px;
  32. border-radius: 32px;
  33. background: rgb(var(--v-theme-primary));
  34. color: rgb(var(--v-theme-on-primary));
  35. @media (max-width: 1350px) {
  36. right: 5%;
  37. }
  38. @media (max-width: 600px) {
  39. bottom: 30px;
  40. right: 15%;
  41. }
  42. }
  43. </style>