motion.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.initMotion = void 0;
  6. const initMotionCommon = duration => ({
  7. animationDuration: duration,
  8. animationFillMode: 'both'
  9. });
  10. // FIXME: origin less code seems same as initMotionCommon. Maybe we can safe remove
  11. const initMotionCommonLeave = duration => ({
  12. animationDuration: duration,
  13. animationFillMode: 'both'
  14. });
  15. const initMotion = (motionCls, inKeyframes, outKeyframes, duration, sameLevel = false) => {
  16. const sameLevelPrefix = sameLevel ? '&' : '';
  17. return {
  18. [`
  19. ${sameLevelPrefix}${motionCls}-enter,
  20. ${sameLevelPrefix}${motionCls}-appear
  21. `]: Object.assign(Object.assign({}, initMotionCommon(duration)), {
  22. animationPlayState: 'paused'
  23. }),
  24. [`${sameLevelPrefix}${motionCls}-leave`]: Object.assign(Object.assign({}, initMotionCommonLeave(duration)), {
  25. animationPlayState: 'paused'
  26. }),
  27. [`
  28. ${sameLevelPrefix}${motionCls}-enter${motionCls}-enter-active,
  29. ${sameLevelPrefix}${motionCls}-appear${motionCls}-appear-active
  30. `]: {
  31. animationName: inKeyframes,
  32. animationPlayState: 'running'
  33. },
  34. [`${sameLevelPrefix}${motionCls}-leave${motionCls}-leave-active`]: {
  35. animationName: outKeyframes,
  36. animationPlayState: 'running',
  37. pointerEvents: 'none'
  38. }
  39. };
  40. };
  41. exports.initMotion = initMotion;