'use strict';

var vue = require('vue');
require('../../../utils/index.cjs');
var _class = require('../../../utils/dom/class.cjs');

function collapseMotion(name = "ant-motion-collapse", appear = true) {
  return {
    name,
    appear,
    css: true,
    onBeforeEnter: (node) => {
      node.style.height = "0px";
      node.style.opacity = "0";
      _class.addClass(node, name);
    },
    onEnter: (node) => {
      vue.nextTick(() => {
        node.style.height = `${node.scrollHeight}px`;
        node.style.opacity = "1";
      });
    },
    onAfterEnter: (node) => {
      if (node) {
        _class.removeClass(node, name);
        node.style.height = null;
        node.style.opacity = null;
      }
    },
    onBeforeLeave: (node) => {
      _class.addClass(node, name);
      node.style.height = `${node.offsetHeight}px`;
      node.style.opacity = null;
    },
    onLeave: (node) => {
      setTimeout(() => {
        node.style.height = "0px";
        node.style.opacity = "0";
      });
    },
    onAfterLeave: (node) => {
      if (node) {
        _class.removeClass(node, name);
        if (node.style) {
          node.style.height = null;
          node.style.opacity = null;
        }
      }
    }
  };
}

exports.collapseMotion = collapseMotion;
//# sourceMappingURL=collapseMotion.cjs.map
