motion.ts 657 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { h, defineComponent, withDirectives, resolveDirective } from 'vue';
  2. /** 封装@vueuse/motion动画库中的自定义指令v-motion */
  3. export default defineComponent({
  4. name: 'Motion',
  5. props: {
  6. delay: {
  7. type: Number,
  8. default: 50,
  9. },
  10. },
  11. render() {
  12. const { delay } = this;
  13. const motion = resolveDirective('motion');
  14. return withDirectives(
  15. h(
  16. 'div',
  17. {},
  18. {
  19. default: () => [this.$slots.default()],
  20. }
  21. ),
  22. [
  23. [
  24. motion,
  25. {
  26. initial: { opacity: 0, y: 100 },
  27. enter: {
  28. opacity: 1,
  29. y: 0,
  30. transition: {
  31. delay,
  32. },
  33. },
  34. },
  35. ],
  36. ]
  37. );
  38. },
  39. });