Transition.vue 1.5 KB

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