Transition.vue 1.5 KB
Newer Older
1
<template>
2
  <PageWrapper title="懒加载自定义动画示例" content="懒加载组件显示动画">
3 4 5 6 7 8 9 10 11
    <div class="lazy-base-demo-wrap">
      <h1>向下滚动</h1>

      <div class="lazy-base-demo-box">
        <LazyContainer transitionName="custom">
          <TargetContent />
        </LazyContainer>
      </div>
    </div>
12
  </PageWrapper>
13 14 15 16 17
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import TargetContent from './TargetContent.vue';
  import { LazyContainer } from '/@/components/Container/index';
18 19
  import { PageWrapper } from '/@/components/Page';

20
  export default defineComponent({
V
vben 已提交
21
    components: { LazyContainer, TargetContent, PageWrapper },
22 23 24 25 26 27
  });
</script>
<style lang="less">
  .lazy-base-demo {
    &-wrap {
      display: flex;
V
vben 已提交
28 29 30
      flex-direction: column;
      align-items: center;
      justify-content: center;
31 32 33
      width: 50%;
      height: 2000px;
      margin: 20px auto;
V
Vben 已提交
34
      background-color: @component-background;
V
vben 已提交
35
      text-align: center;
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    }

    &-box {
      width: 300px;
      height: 300px;
    }

    h1 {
      height: 1300px;
      margin: 20px 0;
    }
  }

  .custom-enter {
    transform: scale(0.4) translate(100%);
V
vben 已提交
51
    opacity: 0;
52 53 54
  }

  .custom-enter-to {
V
vben 已提交
55
    opacity: 1;
56 57 58 59 60 61 62 63 64 65
  }

  .custom-enter-active {
    position: absolute;
    top: 0;
    width: 100%;
    transition: all 0.5s;
  }

  .custom-leave {
V
vben 已提交
66
    opacity: 1;
67 68 69 70
  }

  .custom-leave-to {
    transform: scale(0.4) translate(-100%);
V
vben 已提交
71
    opacity: 0;
72 73 74 75 76 77
  }

  .custom-leave-active {
    transition: all 0.5s;
  }
</style>