import { COMPONENT_CONTAINER_ID } from "../../../constant";

/**
 * @author 谦彧 <zhangmian.zm@alipay.com>
 * @date 2024/9/17
 */
export var createPreloadIframe = function createPreloadIframe(containerId) {
  var iframe = document.createElement('iframe');
  var none = '1px';
  var width = '1px';
  iframe.id = containerId;
  iframe.style.height = none;
  iframe.style.width = width;
  iframe.style.border = none;
  iframe.style.opacity = '0';
  iframe.style.overflow = 'hidden';
  return iframe;
};
export var createIframe = function createIframe(containerId) {
  var iframe = document.createElement('iframe');
  var iframeId = containerId;
  var none = '0';
  var width = '100%';
  iframe.id = iframeId;
  iframe.style.height = none;
  iframe.style.width = width;
  iframe.style.border = none;
  iframe.style.opacity = none;
  iframe.style.overflow = 'hidden';
  return iframe;
};
export var startSizeChangeAnim = function startSizeChangeAnim(target, height, animationStyleId) {
  // 弹出和弹入动画
  var runkeyframes = "@keyframes ".concat(COMPONENT_CONTAINER_ID, "-slide-in {\n            0% {\n              height: 1px;\n            }\n            100% {\n              height: ").concat(height, "px;\n            }\n          }\n          @keyframes ").concat(COMPONENT_CONTAINER_ID, "-slide-out {\n            0% {\n              height: ").concat(height, "px;\n              opacity: 1;\n            }\n            50% {\n              opacity: 1;\n            }\n            100% {\n              height: 1px;\n              opacity: 0;\n            }\n          }");
  // 创建style标签
  var style = document.createElement('style');
  style.id = animationStyleId;
  // 设置style属性
  style.type = 'text/css';
  // 将 keyframes样式写入style内
  style.innerHTML = runkeyframes;
  // 将style样式存放到head标签
  document.getElementsByTagName('head')[0].appendChild(style);
  // size变动时动画
  setTimeout(function () {
    target.style.transition = 'height 0.28s ease-in-out';
  }, 500);
};