motion.js 1.6 KB

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