TransitionViewNavigation.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useViewTransition } from './useViewTransition.ts'
  4. const { viewTransition } = useViewTransition()
  5. </script>
  6. <template>
  7. <main class="grid flex-1 overflow-hidden">
  8. <Transition :name="viewTransition">
  9. <slot></slot>
  10. </Transition>
  11. </main>
  12. </template>
  13. <style scoped>
  14. /* First example idea from: https://codesandbox.io/s/zq5mw2zk9x */
  15. main {
  16. grid-template: 'main';
  17. }
  18. main > * {
  19. grid-area: main; /* Transition: make sections overlap on same cell */
  20. }
  21. /* next */
  22. .next-leave-to {
  23. animation: leaveToLeft 300ms both cubic-bezier(0.19, 0.61, 0.44, 1);
  24. z-index: 0;
  25. }
  26. .next-enter-to {
  27. animation: enterFromRight 400ms both cubic-bezier(0.19, 0.61, 0.44, 1);
  28. z-index: 1;
  29. }
  30. @keyframes leaveToLeft {
  31. from {
  32. transform: translateX(0);
  33. }
  34. to {
  35. transform: translateX(-25%);
  36. filter: brightness(0.4);
  37. }
  38. }
  39. @keyframes enterFromRight {
  40. from {
  41. transform: translateX(100%);
  42. }
  43. to {
  44. transform: translateX(0);
  45. }
  46. }
  47. /* prev */
  48. .prev-leave-to {
  49. animation: leaveToRight 400ms both cubic-bezier(0.19, 0.61, 0.44, 1);
  50. z-index: 1;
  51. }
  52. .prev-enter-to {
  53. animation: enterFromLeft 300ms both cubic-bezier(0.19, 0.61, 0.44, 1);
  54. z-index: 0;
  55. }
  56. @keyframes enterFromLeft {
  57. from {
  58. transform: translateX(-25%);
  59. filter: brightness(0.5);
  60. }
  61. to {
  62. transform: translateX(0);
  63. }
  64. }
  65. @keyframes leaveToRight {
  66. from {
  67. transform: translateX(0);
  68. filter: brightness(0.9);
  69. }
  70. to {
  71. transform: translateX(100%);
  72. filter: brightness(0.8);
  73. }
  74. }
  75. </style>