Transition.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="p-4 lazy-base-demo">
  3. <Alert message="自定义动画" description="懒加载组件显示动画" type="info" show-icon />
  4. <div class="lazy-base-demo-wrap">
  5. <h1>向下滚动</h1>
  6. <div class="lazy-base-demo-box">
  7. <LazyContainer transitionName="custom">
  8. <TargetContent />
  9. </LazyContainer>
  10. </div>
  11. </div>
  12. </div>
  13. </template>
  14. <script lang="ts">
  15. import { defineComponent } from 'vue';
  16. import { Skeleton, Alert } from 'ant-design-vue';
  17. import TargetContent from './TargetContent.vue';
  18. import { LazyContainer } from '/@/components/Container/index';
  19. export default defineComponent({
  20. components: { LazyContainer, TargetContent, Skeleton, Alert },
  21. setup() {
  22. return {};
  23. },
  24. });
  25. </script>
  26. <style lang="less">
  27. .lazy-base-demo {
  28. &-wrap {
  29. display: flex;
  30. width: 50%;
  31. height: 2000px;
  32. margin: 20px auto;
  33. text-align: center;
  34. background: #fff;
  35. justify-content: center;
  36. flex-direction: column;
  37. align-items: center;
  38. }
  39. &-box {
  40. width: 300px;
  41. height: 300px;
  42. }
  43. h1 {
  44. height: 1300px;
  45. margin: 20px 0;
  46. }
  47. }
  48. .custom-enter {
  49. opacity: 0;
  50. transform: scale(0.4) translate(100%);
  51. }
  52. .custom-enter-to {
  53. opacity: 1;
  54. }
  55. .custom-enter-active {
  56. position: absolute;
  57. top: 0;
  58. width: 100%;
  59. transition: all 0.5s;
  60. }
  61. .custom-leave {
  62. opacity: 1;
  63. }
  64. .custom-leave-to {
  65. opacity: 0;
  66. transform: scale(0.4) translate(-100%);
  67. }
  68. .custom-leave-active {
  69. transition: all 0.5s;
  70. }
  71. </style>