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. 404
      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 "./detectElementResize";
export * from "./function"; export * from "./function";
export * from "./load"; export * from "./load";

404
src/core/utils/color.js

@ -1,204 +1,206 @@
import { parseInt, parseFloat, isNull, isKey } from "../2.base"; 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; return false;
}, }
// 获取对比颜色 return color[0] === "#" && color.length === 7;
getContrastColor(color) { }
if (!color || !this.isColor(color)) {
return ""; export function isDarkColor(hex) {
} if (!hex || !isHexColor(hex)) {
if (this.isDarkColor(color)) { return false;
return "#FFFFFF"; }
} const rgb = rgb2json(hex2rgb(hex));
const grayLevel = Math.round(rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
return "#3D4D66"; if (grayLevel < 192/** 网上给的是140**/) {
}, return true;
}
rgb2hex(rgbColour) {
if (!rgbColour || rgbColour.substr(0, 3) !== "rgb") { return false;
return ""; }
}
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g); // 获取对比颜色
const red = parseInt(rgbValues[0]); export function getContrastColor(color) {
const green = parseInt(rgbValues[1]); if (!color || !isColor(color)) {
const blue = parseInt(rgbValues[2]); return "";
}
const hexColour = `#${this.int2hex(red)}${this.int2hex(green)}${this.int2hex(blue)}`; if (isDarkColor(color)) {
return "#FFFFFF";
return hexColour; }
},
return "#3D4D66";
_hue2rgb(m1, m2, h) { }
h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; export function rgb2hex(rgbColour) {
if (h * 2 < 1) return m2; if (!rgbColour || rgbColour.substr(0, 3) !== "rgb") {
if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; return "";
}
return m1; const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
}, const red = parseInt(rgbValues[0]);
const green = parseInt(rgbValues[1]);
hsl2rgb(hsl) { const blue = parseInt(rgbValues[2]);
const h = hsl[0], s = hsl[1], l = hsl[2];
const m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s; const hexColour = `#${int2hex(red)}${int2hex(green)}${int2hex(blue)}`;
const m1 = l * 2 - m2;
return hexColour;
return [this._hue2rgb(m1, m2, h + 0.33333), }
this._hue2rgb(m1, m2, h),
this._hue2rgb(m1, m2, h - 0.33333)]; 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;
rgb2hsl(rgb) { if (h * 2 < 1) return m2;
let h, s; if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
const r = rgb[0], g = rgb[1], b = rgb[2];
const min = Math.min(r, Math.min(g, b)); return m1;
const max = Math.max(r, Math.max(g, b)); }
const delta = max - min;
const l = (min + max) / 2; export function hsl2rgb(hsl) {
s = 0; const h = hsl[0], s = hsl[1], l = hsl[2];
if (l > 0 && l < 1) { const m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); const m1 = l * 2 - m2;
}
h = 0; return [
if (delta > 0) { _hue2rgb(m1, m2, h + 0.33333),
if (max === r && max !== g) h += (g - b) / delta; _hue2rgb(m1, m2, h),
if (max === g && max !== b) h += (2 + (b - r) / delta); _hue2rgb(m1, m2, h - 0.33333)
if (max === b && max !== r) h += (4 + (r - g) / delta); ];
h /= 6; }
}
export function rgb2hsl(rgb) {
return [h, s, l]; let h, s;
}, const r = rgb[0], g = rgb[1], b = rgb[2];
const min = Math.min(r, Math.min(g, b));
rgb2json(rgbColour) { const max = Math.max(r, Math.max(g, b));
if (!rgbColour) { const delta = max - min;
return {}; const l = (min + max) / 2;
} s = 0;
if (!this.isRGBColor(rgbColour)) { if (l > 0 && l < 1) {
return {}; s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
} }
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g); h = 0;
if (delta > 0) {
return { if (max === r && max !== g) h += (g - b) / delta;
r: parseInt(rgbValues[0]), if (max === g && max !== b) h += (2 + (b - r) / delta);
g: parseInt(rgbValues[1]), if (max === b && max !== r) h += (4 + (r - g) / delta);
b: parseInt(rgbValues[2]), h /= 6;
}; }
},
return [h, s, l];
rgba2json(rgbColour) { }
if (!rgbColour) {
return {}; export function rgb2json(rgbColour) {
} if (!rgbColour) {
const rgbValues = rgbColour.match(/\d+(\.\d+)?/g); return {};
}
return { if (!isRGBColor(rgbColour)) {
r: parseInt(rgbValues[0]), return {};
g: parseInt(rgbValues[1]), }
b: parseInt(rgbValues[2]), const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
a: parseFloat(rgbValues[3]),
}; return {
}, r: parseInt(rgbValues[0]),
g: parseInt(rgbValues[1]),
json2rgb(rgb) { b: parseInt(rgbValues[2]),
if (!isKey(rgb.r) || !isKey(rgb.g) || !isKey(rgb.b)) { };
return ""; }
}
export function rgba2json(rgbColour) {
return `rgb(${rgb.r},${rgb.g},${rgb.b})`; if (!rgbColour) {
}, return {};
}
json2rgba(rgba) { const rgbValues = rgbColour.match(/\d+(\.\d+)?/g);
if (!isKey(rgba.r) || !isKey(rgba.g) || !isKey(rgba.b)) {
return ""; return {
} r: parseInt(rgbValues[0]),
g: parseInt(rgbValues[1]),
return `rgba(${rgba.r},${rgba.g},${rgba.b},${rgba.a})`; b: parseInt(rgbValues[2]),
}, a: parseFloat(rgbValues[3]),
};
int2hex(strNum) { }
const hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
export function json2rgb(rgb) {
return `${hexdig[strNum >>> 4]}${hexdig[strNum & 15]}`; if (!isKey(rgb.r) || !isKey(rgb.g) || !isKey(rgb.b)) {
}, return "";
}
hex2rgb(color) {
if (!color) { return `rgb(${rgb.r},${rgb.g},${rgb.b})`;
return ""; }
}
if (!this.isHexColor(color)) { export function json2rgba(rgba) {
return color; if (!isKey(rgba.r) || !isKey(rgba.g) || !isKey(rgba.b)) {
} return "";
let tempValue = "rgb(", colorArray; }
if (color.length === 7) { return `rgba(${rgba.r},${rgba.g},${rgba.b},${rgba.a})`;
colorArray = [parseInt(`0x${color.substring(1, 3)}`), }
parseInt(`0x${color.substring(3, 5)}`),
parseInt(`0x${color.substring(5, 7)}`)]; export function int2hex(strNum) {
} else if (color.length === 4) { const hexdig = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
colorArray = [parseInt(`0x${color.substring(1, 2)}`),
parseInt(`0x${color.substring(2, 3)}`), return `${hexdig[strNum >>> 4]}${hexdig[strNum & 15]}`;
parseInt(`0x${color.substring(3, 4)}`)]; }
}
tempValue += `${colorArray[0]},`; export function hex2rgb(color) {
tempValue += `${colorArray[1]},`; if (!color) {
tempValue += `${colorArray[2]})`; return "";
}
return tempValue; if (!isHexColor(color)) {
}, return color;
}
rgba2rgb(rgbColor, bgColor) { let tempValue = "rgb(", colorArray;
if (isNull(bgColor)) {
bgColor = 1; if (color.length === 7) {
} colorArray = [
if (rgbColor.substr(0, 4) !== "rgba") { parseInt(`0x${color.substring(1, 3)}`),
return ""; parseInt(`0x${color.substring(3, 5)}`),
} parseInt(`0x${color.substring(5, 7)}`)
const rgbValues = rgbColor.match(/\d+(\.\d+)?/g); ];
if (rgbValues.length < 4) { } else if (color.length === 4) {
return ""; colorArray = [
} parseInt(`0x${color.substring(1, 2)}`),
const R = parseFloat(rgbValues[0]); parseInt(`0x${color.substring(2, 3)}`),
const G = parseFloat(rgbValues[1]); parseInt(`0x${color.substring(3, 4)}`)
const B = parseFloat(rgbValues[2]); ];
const A = parseFloat(rgbValues[3]); }
tempValue += `${colorArray[0]},`;
return `rgb(${Math.floor(255 * (bgColor * (1 - A)) + R * A)},${ tempValue += `${colorArray[1]},`;
Math.floor(255 * (bgColor * (1 - A)) + G * A)},${ tempValue += `${colorArray[2]})`;
Math.floor(255 * (bgColor * (1 - A)) + B * A)})`;
}, return tempValue;
}
...DOMUtils,
}; 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操作的通用函数 * 对DOM操作的通用函数
*/ */
import { each, isEmpty, isNull } from "../../2.base"; import { each, isEmpty, isNull } from "../2.base";
export function ready(fn) { export function ready(fn) {
BI.Widget._renderEngine.createElement(document).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++) { for (i = 0; i < directions.length; i++) {
direct = directions[i]; direct = directions[i];
switch (direct) { switch (direct) {
case "left": case "left":
leftRight.push(direct); leftRight.push(direct);
break; break;
case "right": case "right":
leftRight.push(direct); leftRight.push(direct);
break; break;
case "top": case "top":
topBottom.push(direct); topBottom.push(direct);
break; break;
case "bottom": case "bottom":
topBottom.push(direct); topBottom.push(direct);
break; break;
case "innerLeft": case "innerLeft":
innerLeftRight.push(direct); innerLeftRight.push(direct);
break; break;
case "innerRight": case "innerRight":
innerLeftRight.push(direct); innerLeftRight.push(direct);
break; break;
default: default:
break; break;
} }
} }
for (i = 0; i < directions.length; i++) { for (i = 0; i < directions.length; i++) {
let tW, tH; let tW, tH;
direct = directions[i]; direct = directions[i];
switch (direct) { switch (direct) {
case "left": case "left":
if (!isNeedAdaptHeight) { if (!isNeedAdaptHeight) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight; tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if (isLeftSpaceEnough(combo, popup, tW)) { if (isLeftSpaceEnough(combo, popup, tW)) {
left = getLeftPosition(combo, popup, tW, container).left; left = getLeftPosition(combo, popup, tW, container).left;
if (topBottom[0] === "bottom") { if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight, container); pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
} else { } else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container); 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) { lrFirst = true;
pos.change = "left"; 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;
lrFirst = true; break;
break; case "top":
case "right": tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (!isNeedAdaptHeight) { if (isTopSpaceEnough(combo, popup, tH)) {
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight; top = getTopPosition(combo, popup, tH, container).top;
if (isRightSpaceEnough(combo, popup, tW)) { if (leftRight[0] === "right") {
left = getRightPosition(combo, popup, tW, container).left; pos = getLeftAlignPosition(combo, popup, tW, container);
if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight, container);
} else { } else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight, container); pos = getRightAlignPosition(combo, popup, tW, container);
} }
pos.dir = `right,${pos.dir}`; pos.dir = `top,${pos.dir}`;
if (tbFirst) { if (lrFirst) {
pos.change = "right"; pos.change = "top";
} }
pos.left = left; pos.top = top;
return pos; return pos;
} }
} if (needAdaptHeight) {
lrFirst = true; isNeedAdaptHeight = 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";
} }
pos.top = top; tbFirst = true;
break;
return pos; case "bottom":
} tW = lrFirst ? extraHeight : extraWidth, tH = lrFirst ? extraWidth : extraHeight;
if (needAdaptHeight) { if (isBottomSpaceEnough(combo, popup, tH)) {
isNeedAdaptHeight = true; top = getBottomPosition(combo, popup, tH, container).top;
} if (leftRight[0] === "right") {
tbFirst = true; pos = getLeftAlignPosition(combo, popup, tW, container);
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);
} else { } else {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight); pos = getRightAlignPosition(combo, popup, tW, container);
} }
pos.dir = `innerLeft,${pos.dir}`; pos.dir = `bottom,${pos.dir}`;
if (tbFirst) { if (lrFirst) {
pos.change = "innerLeft"; pos.change = "bottom";
} }
pos.left = left; pos.top = top;
return pos; return pos;
} }
} if (needAdaptHeight) {
lrFirst = true; isNeedAdaptHeight = true;
break; }
case "innerRight": tbFirst = true;
if (!isNeedAdaptHeight) { break;
tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? extraWidth : extraHeight; case "innerLeft":
if (isInnerRightSpaceEnough(combo, popup, tW)) { if (!isNeedAdaptHeight) {
left = getInnerRightPosition(combo, popup, tW).left; tW = tbFirst ? extraHeight : extraWidth, tH = tbFirst ? 0 : extraHeight;
if (topBottom[0] === "bottom") { if (isInnerLeftSpaceEnough(combo, popup, tW)) {
pos = getTopAlignPosition(combo, popup, tH, needAdaptHeight); left = getInnerLeftPosition(combo, popup, tW).left;
} else { if (topBottom[0] === "bottom") {
pos = getBottomAlignPosition(combo, popup, tH, needAdaptHeight); 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) { lrFirst = true;
pos.change = "innerRight"; 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;
break; default:
default: break;
break;
} }
} }
// 此处为四个方向放不下时挑空间最大的方向去放置, 也就是说我设置了弹出方向为"bottom,left", // 此处为四个方向放不下时挑空间最大的方向去放置, 也就是说我设置了弹出方向为"bottom,left",
// 最后发现实际弹出方向可能是"top,left",那么此时外界获取popup的方向应该是"top,left" // 最后发现实际弹出方向可能是"top,left",那么此时外界获取popup的方向应该是"top,left"
switch (directions[0]) { switch (directions[0]) {
case "left": case "left":
case "right": case "right":
if (isRightSpaceLarger(combo)) { if (isRightSpaceLarger(combo)) {
left = getRightAdaptPosition(combo, popup, extraWidth, container).left; left = getRightAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "right"; firstDir = "right";
} else { } else {
left = getLeftAdaptPosition(combo, popup, extraWidth, container).left; left = getLeftAdaptPosition(combo, popup, extraWidth, container).left;
firstDir = "left"; firstDir = "left";
} }
if (topBottom[0] === "bottom") { if (topBottom[0] === "bottom") {
pos = getTopAlignPosition(combo, popup, extraHeight, needAdaptHeight); 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.left = left;
pos.dir = `${firstDir},${pos.dir}`; pos.dir = `${firstDir},${pos.dir}`;
return pos; return pos;
} default :
pos = getBottomAlignPosition(combo, popup, extraHeight, needAdaptHeight); if (isBottomSpaceLarger(combo)) {
pos.left = left; top = getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
pos.dir = `${firstDir},${pos.dir}`; firstDir = "bottom";
} else {
return pos; top = getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top;
default : firstDir = "top";
if (isBottomSpaceLarger(combo)) { }
top = getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top; if (leftRight[0] === "right") {
firstDir = "bottom"; pos = getLeftAlignPosition(combo, popup, extraWidth, container);
} else { pos.top = top;
top = getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight, container).top; pos.dir = `${firstDir},${pos.dir}`;
firstDir = "top";
} return pos;
if (leftRight[0] === "right") { }
pos = getLeftAlignPosition(combo, popup, extraWidth, container); pos = getRightAlignPosition(combo, popup, extraWidth, container);
pos.top = top; pos.top = top;
pos.dir = `${firstDir},${pos.dir}`; pos.dir = `${firstDir},${pos.dir}`;
return pos; 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); popup.resetHeight && popup.resetHeight(maxHeight);
const position = getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], positionRelativeElement); const position = getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], positionRelativeElement);
switch (offsetStyle) { switch (offsetStyle) {
case "center": case "center":
if (position.change) { if (position.change) {
const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement); const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top; position.top = p.top;
} else { } else {
const p = getCenterAdaptPosition(combo, popup, positionRelativeElement); const p = getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left; position.left = p.left;
} }
break; break;
case "middle": case "middle":
if (position.change) { if (position.change) {
const p = getCenterAdaptPosition(combo, popup, positionRelativeElement); const p = getCenterAdaptPosition(combo, popup, positionRelativeElement);
position.left = p.left; position.left = p.left;
} else { } else {
const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement); const p = getMiddleAdaptPosition(combo, popup, positionRelativeElement);
position.top = p.top; position.top = p.top;
} }
break; break;
default: default:
break; break;
} }
if (needAdaptHeight === true) { if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(viewportBounds.height - position.top - (positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0), maxHeight)); 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 "./events";
export * from "./i18n"; export * from "./i18n";
export { makeFirstPY } from "./chinesePY"; 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