collapseMotion.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. var collapseMotion = function collapseMotion() {
  9. var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ant-motion-collapse';
  10. var appear = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
  11. return {
  12. name: name,
  13. appear: appear,
  14. css: true,
  15. onBeforeEnter: function onBeforeEnter(node) {
  16. node.style.height = '0px';
  17. node.style.opacity = '0';
  18. (0, _class.addClass)(node, name);
  19. },
  20. onEnter: function onEnter(node) {
  21. (0, _vue.nextTick)(function () {
  22. node.style.height = "".concat(node.scrollHeight, "px");
  23. node.style.opacity = '1';
  24. });
  25. },
  26. onAfterEnter: function 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: function onBeforeLeave(node) {
  34. (0, _class.addClass)(node, name);
  35. node.style.height = "".concat(node.offsetHeight, "px");
  36. node.style.opacity = null;
  37. },
  38. onLeave: function onLeave(node) {
  39. setTimeout(function () {
  40. node.style.height = '0px';
  41. node.style.opacity = '0';
  42. });
  43. },
  44. onAfterLeave: function 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 = collapseMotion;
  56. exports.default = _default;