collapseMotion.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _vue = require("vue");
  7. var _class = require("../vc-util/Dom/class");
  8. const collapseMotion = function () {
  9. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ant-motion-collapse';
  10. let appear = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  11. return {
  12. name,
  13. appear,
  14. css: true,
  15. onBeforeEnter: node => {
  16. node.style.height = '0px';
  17. node.style.opacity = '0';
  18. (0, _class.addClass)(node, name);
  19. },
  20. onEnter: node => {
  21. (0, _vue.nextTick)(() => {
  22. node.style.height = `${node.scrollHeight}px`;
  23. node.style.opacity = '1';
  24. });
  25. },
  26. onAfterEnter: node => {
  27. if (node) {
  28. (0, _class.removeClass)(node, name);
  29. node.style.height = null;
  30. node.style.opacity = null;
  31. }
  32. },
  33. onBeforeLeave: node => {
  34. (0, _class.addClass)(node, name);
  35. node.style.height = `${node.offsetHeight}px`;
  36. node.style.opacity = null;
  37. },
  38. onLeave: node => {
  39. setTimeout(() => {
  40. node.style.height = '0px';
  41. node.style.opacity = '0';
  42. });
  43. },
  44. onAfterLeave: node => {
  45. if (node) {
  46. (0, _class.removeClass)(node, name);
  47. if (node.style) {
  48. node.style.height = null;
  49. node.style.opacity = null;
  50. }
  51. }
  52. }
  53. };
  54. };
  55. var _default = exports.default = collapseMotion;