Browse Source

KERNEL-14066 feat: case/tree和case/ztree

es6
zsmj 2 years ago
parent
commit
aa6fcad0bf
  1. 1
      src/core/platform/web/index.js
  2. 406
      src/core/utils/color.js
  3. 368
      src/core/utils/dom.js
  4. 10
      src/core/utils/index.js

1
src/core/platform/web/index.js

@ -1,4 +1,3 @@
export * as DOM from "./dom";
export * from "./detectElementResize";
export * from "./function";
export * from "./load";

406
src/core/utils/color.js

@ -1,204 +1,206 @@
import { parseInt, parseFloat, isNull, isKey } from "../2.base";
import * as DOMUtils from "../platform/web/dom";
export const DOM = {
isColor(color) {
return color && (this.isRGBColor(color) || this.isHexColor(color));
},
isRGBColor(color) {
if (!color) {
return false;
}
return color.substr(0, 3) === "rgb";
},
isHexColor(color) {
if (!color) {
return false;
}
return color[0] === "#" && color.length === 7;
},
isDarkColor(hex) {
if (!hex || !this.isHexColor(hex)) {
return false;
}
const rgb = this.rgb2json(this.hex2rgb(hex));
const grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
if (grayLevel < 192/** 网上给的是140**/) {
return true;
}
export function isColor(color) {
return color && (isRGBColor(color) || isHexColor(color));
}
export function isRGBColor(color) {
if (!color) {
return false;
}
return color.substr(0, 3) === "rgb";
}
export function isHexColor(color) {
if (!color) {
return false;
},
// 获取对比颜色
getContrastColor(color) {
if (!color || !this.isColor(color)) {
return "";
}
if (this.isDarkColor(color)) {
return "#FFFFFF";
}
return "#3D4D66";
},
rgb2hex(rgbColour) {
if (!rgbColour || rgbColour.substr(0, 3) !== "rgb") {
return "";
}
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
const red = parseInt(rgbValues[0]);
const green = parseInt(rgbValues[1]);
const blue = parseInt(rgbValues[2]);
const hexColour = `#${this.int2hex(red)}${this.int2hex(green)}${this.int2hex(blue)}`;
return hexColour;
},
_hue2rgb(m1, m2, h) {
h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
if (h * 2 < 1) return m2;
if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
return m1;
},
hsl2rgb(hsl) {
const h = hsl[0], s = hsl[1], l = hsl[2];
const m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
const m1 = l * 2 - m2;
return [this._hue2rgb(m1, m2, h + 0.33333),
this._hue2rgb(m1, m2, h),
this._hue2rgb(m1, m2, h - 0.33333)];
},
rgb2hsl(rgb) {
let h, s;
const r = rgb[0], g = rgb[1], b = rgb[2];
const min = Math.min(r, Math.min(g, b));
const max = Math.max(r, Math.max(g, b));
const delta = max - min;
const l = (min + max) / 2;
s = 0;
if (l > 0 && l < 1) {
s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
}
h = 0;
if (delta > 0) {
if (max === r && max !== g) h += (g - b) / delta;
if (max === g && max !== b) h += (2 + (b - r) / delta);
if (max === b && max !== r) h += (4 + (r - g) / delta);
h /= 6;
}
return [h, s, l];
},
rgb2json(rgbColour) {
if (!rgbColour) {
return {};
}
if (!this.isRGBColor(rgbColour)) {
return {};
}
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: parseInt(rgbValues[0]),
g: parseInt(rgbValues[1]),
b: parseInt(rgbValues[2]),
};
},
rgba2json(rgbColour) {
if (!rgbColour) {
return {};
}
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: parseInt(rgbValues[0]),
g: parseInt(rgbValues[1]),
b: parseInt(rgbValues[2]),
a: parseFloat(rgbValues[3]),
};
},
json2rgb(rgb) {
if (!isKey(rgb.r) || !isKey(rgb.g) || !isKey(rgb.b)) {
return "";
}
return `rgb(${rgb.r},${rgb.g},${rgb.b})`;
},
json2rgba(rgba) {
if (!isKey(rgba.r) || !isKey(rgba.g) || !isKey(rgba.b)) {
return "";
}
return `rgba(${rgba.r},${rgba.g},${rgba.b},${rgba.a})`;
},
int2hex(strNum) {
const hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
return `${hexdig[strNum >>> 4]}${hexdig[strNum & 15]}`;
},
hex2rgb(color) {
if (!color) {
return "";
}
if (!this.isHexColor(color)) {
return color;
}
let tempValue = "rgb(", colorArray;
if (color.length === 7) {
colorArray = [parseInt(`0x${color.substring(1, 3)}`),
parseInt(`0x${color.substring(3, 5)}`),
parseInt(`0x${color.substring(5, 7)}`)];
} else if (color.length === 4) {
colorArray = [parseInt(`0x${color.substring(1, 2)}`),
parseInt(`0x${color.substring(2, 3)}`),
parseInt(`0x${color.substring(3, 4)}`)];
}
tempValue += `${colorArray[0]},`;
tempValue += `${colorArray[1]},`;
tempValue += `${colorArray[2]})`;
return tempValue;
},
rgba2rgb(rgbColor, bgColor) {
if (isNull(bgColor)) {
bgColor = 1;
}
if (rgbColor.substr(0, 4) !== "rgba") {
return "";
}
const rgbValues = rgbColor.match(/\d+(\.\d+)?/g);
if (rgbValues.length < 4) {
return "";
}
const R = parseFloat(rgbValues[0]);
const G = parseFloat(rgbValues[1]);
const B = parseFloat(rgbValues[2]);
const A = parseFloat(rgbValues[3]);
return `rgb(${Math.floor(255 * (bgColor * (1 - A)) + R * A)},${
Math.floor(255 * (bgColor * (1 - A)) + G * A)},${
Math.floor(255 * (bgColor * (1 - A)) + B * A)})`;
},
...DOMUtils,
};
}
return color[0] === "#" && color.length === 7;
}
export function isDarkColor(hex) {
if (!hex || !isHexColor(hex)) {
return false;
}
const rgb = rgb2json(hex2rgb(hex));
const grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
if (grayLevel < 192/** 网上给的是140**/) {
return true;
}
return false;
}
// 获取对比颜色
export function getContrastColor(color) {
if (!color || !isColor(color)) {
return "";
}
if (isDarkColor(color)) {
return "#FFFFFF";
}
return "#3D4D66";
}
export function rgb2hex(rgbColour) {
if (!rgbColour || rgbColour.substr(0, 3) !== "rgb") {
return "";
}
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
const red = parseInt(rgbValues[0]);
const green = parseInt(rgbValues[1]);
const blue = parseInt(rgbValues[2]);
const hexColour = `#${int2hex(red)}${int2hex(green)}${int2hex(blue)}`;
return hexColour;
}
function _hue2rgb(m1, m2, h) {
h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
if (h * 2 < 1) return m2;
if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
return m1;
}
export function hsl2rgb(hsl) {
const h = hsl[0], s = hsl[1], l = hsl[2];
const m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
const m1 = l * 2 - m2;
return [
_hue2rgb(m1, m2, h + 0.33333),
_hue2rgb(m1, m2, h),
_hue2rgb(m1, m2, h - 0.33333)
];
}
export function rgb2hsl(rgb) {
let h, s;
const r = rgb[0], g = rgb[1], b = rgb[2];
const min = Math.min(r, Math.min(g, b));
const max = Math.max(r, Math.max(g, b));
const delta = max - min;
const l = (min + max) / 2;
s = 0;
if (l > 0 && l < 1) {
s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
}
h = 0;
if (delta > 0) {
if (max === r && max !== g) h += (g - b) / delta;
if (max === g && max !== b) h += (2 + (b - r) / delta);
if (max === b && max !== r) h += (4 + (r - g) / delta);
h /= 6;
}
return [h, s, l];
}
export function rgb2json(rgbColour) {
if (!rgbColour) {
return {};
}
if (!isRGBColor(rgbColour)) {
return {};
}
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: parseInt(rgbValues[0]),
g: parseInt(rgbValues[1]),
b: parseInt(rgbValues[2]),
};
}
export function rgba2json(rgbColour) {
if (!rgbColour) {
return {};
}
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
return {
r: parseInt(rgbValues[0]),
g: parseInt(rgbValues[1]),
b: parseInt(rgbValues[2]),
a: parseFloat(rgbValues[3]),
};
}
export function json2rgb(rgb) {
if (!isKey(rgb.r) || !isKey(rgb.g) || !isKey(rgb.b)) {
return "";
}
return `rgb(${rgb.r},${rgb.g},${rgb.b})`;
}
export function json2rgba(rgba) {
if (!isKey(rgba.r) || !isKey(rgba.g) || !isKey(rgba.b)) {
return "";
}
return `rgba(${rgba.r},${rgba.g},${rgba.b},${rgba.a})`;
}
export function int2hex(strNum) {
const hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
return `${hexdig[strNum >>> 4]}${hexdig[strNum & 15]}`;
}
export function hex2rgb(color) {
if (!color) {
return "";
}
if (!isHexColor(color)) {
return color;
}
let tempValue = "rgb(", colorArray;
if (color.length === 7) {
colorArray = [
parseInt(`0x${color.substring(1, 3)}`),
parseInt(`0x${color.substring(3, 5)}`),
parseInt(`0x${color.substring(5, 7)}`)
];
} else if (color.length === 4) {
colorArray = [
parseInt(`0x${color.substring(1, 2)}`),
parseInt(`0x${color.substring(2, 3)}`),
parseInt(`0x${color.substring(3, 4)}`)
];
}
tempValue += `${colorArray[0]},`;
tempValue += `${colorArray[1]},`;
tempValue += `${colorArray[2]})`;
return tempValue;
}
export function rgba2rgb(rgbColor, bgColor) {
if (isNull(bgColor)) {
bgColor = 1;
}
if (rgbColor.substr(0, 4) !== "rgba") {
return "";
}
const rgbValues = rgbColor.match(/\d+(\.\d+)?/g);
if (rgbValues.length < 4) {
return "";
}
const R = parseFloat(rgbValues[0]);
const G = parseFloat(rgbValues[1]);
const B = parseFloat(rgbValues[2]);
const A = parseFloat(rgbValues[3]);
return `rgb(${Math.floor(255 * (bgColor * (1 - A)) + R * A)},${
Math.floor(255 * (bgColor * (1 - A)) + G * A)},${
Math.floor(255 * (bgColor * (1 - A)) + B * A)})`;
}

368
src/core/platform/web/dom.js → src/core/utils/dom.js

@ -1,7 +1,7 @@
/**
* 对DOM操作的通用函数
*/
import { each, isEmpty, isNull } from "../../2.base";
import { each, isEmpty, isNull } from "../2.base";
export function ready(fn) {
BI.Widget._renderEngine.createElement(document).ready(fn);
@ -502,208 +502,208 @@ export function getComboPositionByDirections(combo, popup, extraWidth, extraHeig
for (i = 0; i < directions.length; i++) {
direct = directions[i];
switch (direct) {
case "left":
leftRight.push(direct);
break;
case "right":
leftRight.push(direct);
break;
case "top":
topBottom.push(direct);
break;
case "bottom":
topBottom.push(direct);
break;
case "innerLeft":
innerLeftRight.push(direct);
break;
case "innerRight":
innerLeftRight.push(direct);
break;
default:
break;
case "left":
leftRight.push(direct);
break;
case "right":
leftRight.push(direct);
break;
case "top":
topBottom.push(direct);
break;
case "bottom":
topBottom.push(direct);
break;
case "innerLeft":
innerLeftRight.push(direct);
break;
case "innerRight":
innerLeftRight.push(direct);
break;
default:
break;
}
}
for (i = 0; i < directions.length; i++) {
let tW, tH;
direct = directions[i];
switch (direct) {
case "left":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if (isLeftSpaceEnough(combo, popup, tW)) {
left = getLeftPosition(combo, popup, tW, container).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container);
case "left":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if (isLeftSpaceEnough(combo, popup, tW)) {
left = getLeftPosition(combo, popup, tW, container).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container);
}
pos.dir = `left,${pos.dir}`;
if (tbFirst) {
pos.change = "left";
}
pos.left = left;
return pos;
}
pos.dir = `left,${pos.dir}`;
if (tbFirst) {
pos.change = "left";
}
lrFirst = true;
break;
case "right":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
if (isRightSpaceEnough(combo, popup, tW)) {
left = getRightPosition(combo, popup, tW, container).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container);
}
pos.dir = `right,${pos.dir}`;
if (tbFirst) {
pos.change = "right";
}
pos.left = left;
return pos;
}
pos.left = left;
return pos;
}
}
lrFirst = true;
break;
case "right":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
if (isRightSpaceEnough(combo, popup, tW)) {
left = getRightPosition(combo, popup, tW, container).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
lrFirst = true;
break;
case "top":
tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (isTopSpaceEnough(combo, popup, tH)) {
top = getTopPosition(combo, popup, tH, container).top;
if (leftRight[0] === "right") {
pos = getLeftAlignPosition(combo, popup, tW, container);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container);
pos = getRightAlignPosition(combo, popup, tW, container);
}
pos.dir = `right,${pos.dir}`;
if (tbFirst) {
pos.change = "right";
pos.dir = `top,${pos.dir}`;
if (lrFirst) {
pos.change = "top";
}
pos.left = left;
pos.top = top;
return pos;
}
}
lrFirst = true;
break;
case "top":
tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (isTopSpaceEnough(combo, popup, tH)) {
top = getTopPosition(combo, popup, tH, container).top;
if (leftRight[0] === "right") {
pos = getLeftAlignPosition(combo, popup, tW, container);
} else {
pos = getRightAlignPosition(combo, popup, tW, container);
}
pos.dir = `top,${pos.dir}`;
if (lrFirst) {
pos.change = "top";
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
pos.top = top;
return pos;
}
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
tbFirst = true;
break;
case "bottom":
tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (isBottomSpaceEnough(combo, popup, tH)) {
top = getBottomPosition(combo, popup, tH, container).top;
if (leftRight[0] === "right") {
pos = getLeftAlignPosition(combo, popup, tW, container);
} else {
pos = getRightAlignPosition(combo, popup, tW, container);
}
pos.dir = `bottom,${pos.dir}`;
if (lrFirst) {
pos.change = "bottom";
}
pos.top = top;
return pos;
}
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
tbFirst = true;
break;
case "innerLeft":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if (isInnerLeftSpaceEnough(combo, popup, tW)) {
left = getInnerLeftPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight);
tbFirst = true;
break;
case "bottom":
tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (isBottomSpaceEnough(combo, popup, tH)) {
top = getBottomPosition(combo, popup, tH, container).top;
if (leftRight[0] === "right") {
pos = getLeftAlignPosition(combo, popup, tW, container);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
pos = getRightAlignPosition(combo, popup, tW, container);
}
pos.dir = `innerLeft,${pos.dir}`;
if (tbFirst) {
pos.change = "innerLeft";
pos.dir = `bottom,${pos.dir}`;
if (lrFirst) {
pos.change = "bottom";
}
pos.left = left;
pos.top = top;
return pos;
}
}
lrFirst = true;
break;
case "innerRight":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
if (isInnerRightSpaceEnough(combo, popup, tW)) {
left = getInnerRightPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
if (needAdaptHeight) {
isNeedAdaptHeight = true;
}
tbFirst = true;
break;
case "innerLeft":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if (isInnerLeftSpaceEnough(combo, popup, tW)) {
left = getInnerLeftPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
}
pos.dir = `innerLeft,${pos.dir}`;
if (tbFirst) {
pos.change = "innerLeft";
}
pos.left = left;
return pos;
}
pos.dir = `innerLeft,${pos.dir}`;
if (tbFirst) {
pos.change = "innerRight";
}
lrFirst = true;
break;
case "innerRight":
if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight;
if (isInnerRightSpaceEnough(combo, popup, tW)) {
left = getInnerRightPosition(combo, popup, tW).left;
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight);
} else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight);
}
pos.dir = `innerLeft,${pos.dir}`;
if (tbFirst) {
pos.change = "innerRight";
}
pos.left = left;
return pos;
}
pos.left = left;
return pos;
}
}
break;
default:
break;
break;
default:
break;
}
}
// 此处为四个方向放不下时挑空间最大的方向去放置, 也就是说我设置了弹出方向为"bottom,left",
// 最后发现实际弹出方向可能是"top,left",那么此时外界获取popup的方向应该是"top,left"
switch (directions[0]) {
case "left":
case "right":
if (isRightSpaceLarger(combo)) {
left = getRightAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "right";
} else {
left = getLeftAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "left";
}
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, extraHeight, needAdaptHeight);
case "left":
case "right":
if (isRightSpaceLarger(combo)) {
left = getRightAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "right";
} else {
left = getLeftAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "left";
}
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, extraHeight, needAdaptHeight);
pos.left = left;
pos.dir = `${firstDir},${pos.dir}`;
return pos;
}
pos = getBottomAlignPosition(combo, popup, extraHeight, needAdaptHeight);
pos.left = left;
pos.dir = `${firstDir},${pos.dir}`;
return pos;
}
pos = getBottomAlignPosition(combo, popup, extraHeight, needAdaptHeight);
pos.left = left;
pos.dir = `${firstDir},${pos.dir}`;
return pos;
default :
if (isBottomSpaceLarger(combo)) {
top = getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
firstDir = "bottom";
} else {
top = getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
firstDir = "top";
}
if (leftRight[0] === "right") {
pos = getLeftAlignPosition(combo, popup, extraWidth, container);
default :
if (isBottomSpaceLarger(combo)) {
top = getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
firstDir = "bottom";
} else {
top = getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
firstDir = "top";
}
if (leftRight[0] === "right") {
pos = getLeftAlignPosition(combo, popup, extraWidth, container);
pos.top = top;
pos.dir = `${firstDir},${pos.dir}`;
return pos;
}
pos = getRightAlignPosition(combo, popup, extraWidth, container);
pos.top = top;
pos.dir = `${firstDir},${pos.dir}`;
return pos;
}
pos = getRightAlignPosition(combo, popup, extraWidth, container);
pos.top = top;
pos.dir = `${firstDir},${pos.dir}`;
return pos;
}
}
@ -716,26 +716,26 @@ export function getComboPosition(combo, popup, extraWidth, extraHeight, needAdap
popup.resetHeight && popup.resetHeight(maxHeight);
const position = getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], positionRelativeElement);
switch (offsetStyle) {
case "center":
if (position.change) {
const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top;
} else {
const p = getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left;
}
break;
case "middle":
if (position.change) {
const p = getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left;
} else {
const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top;
}
break;
default:
break;
case "center":
if (position.change) {
const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top;
} else {
const p = getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left;
}
break;
case "middle":
if (position.change) {
const p = getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left;
} else {
const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top;
}
break;
default:
break;
}
if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(viewportBounds.height - position.top - (positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0), maxHeight));

10
src/core/utils/index.js

@ -1,4 +1,12 @@
export * from "./events";
export * from "./i18n";
export { makeFirstPY } from "./chinesePY";
export { DOM } from "./color";
import * as platformDom from "./dom";
import * as colorDom from "./color";
export const DOM = {
...platformDom,
...colorDom
};

Loading…
Cancel
Save