'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var _class = require('../../vc-util/Dom/class.js');

const 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.default = collapseMotion;
//# sourceMappingURL=collapseMotion.js.map
