mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-08-17 11:11:47 +08:00
fix: TextContent autoHeight
This commit is contained in:
parent
3b6b534211
commit
3aab8f3987
@ -18,10 +18,6 @@ const iconsProps = {
|
|||||||
props: ['loc']
|
props: ['loc']
|
||||||
} satisfies SetupComponentOptions<IconsProps>;
|
} satisfies SetupComponentOptions<IconsProps>;
|
||||||
|
|
||||||
type PathGenerator = (width: number, height: number) => Path2D;
|
|
||||||
type PadFn = (
|
|
||||||
divisor: number
|
|
||||||
) => [left: number, right: number, top: number, bottom: number];
|
|
||||||
type IconLoc = [
|
type IconLoc = [
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
@ -30,6 +26,9 @@ type IconLoc = [
|
|||||||
cx: number,
|
cx: number,
|
||||||
cy: number
|
cy: number
|
||||||
];
|
];
|
||||||
|
type IconPad = [left: number, right: number, top: number, bottom: number];
|
||||||
|
type PathGenerator = (width: number, height: number) => Path2D;
|
||||||
|
type PadFn = (divisor: number) => IconPad;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param loc 图标位置信息
|
* @param loc 图标位置信息
|
||||||
@ -51,7 +50,7 @@ function pad(
|
|||||||
width: number,
|
width: number,
|
||||||
height: number,
|
height: number,
|
||||||
divisor: number
|
divisor: number
|
||||||
): [left: number, right: number, top: number, bottom: number] {
|
): IconPad {
|
||||||
return [
|
return [
|
||||||
x + width / divisor, // left
|
x + width / divisor, // left
|
||||||
x + width - width / divisor, // right
|
x + width - width / divisor, // right
|
||||||
|
@ -117,7 +117,7 @@ export const TextContent = defineComponent<
|
|||||||
TextContentEmits,
|
TextContentEmits,
|
||||||
keyof TextContentEmits
|
keyof TextContentEmits
|
||||||
>((props, { emit, expose }) => {
|
>((props, { emit, expose }) => {
|
||||||
const loc = ref<ElementLocator>(
|
const loc = shallowRef<ElementLocator>(
|
||||||
(props.loc?.slice() as ElementLocator) ?? []
|
(props.loc?.slice() as ElementLocator) ?? []
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -160,7 +160,8 @@ export const TextContent = defineComponent<
|
|||||||
const updateLoc = () => {
|
const updateLoc = () => {
|
||||||
const height = getHeight();
|
const height = getHeight();
|
||||||
if (props.autoHeight) {
|
if (props.autoHeight) {
|
||||||
const [x = 0, y = 0, width = 200, , ax = 0, ay = 0] = loc.value;
|
const [x = 0, y = 0, width = props.width, , ax = 0, ay = 0] =
|
||||||
|
loc.value;
|
||||||
loc.value = [x, y, width, height, ax, ay];
|
loc.value = [x, y, width, height, ax, ay];
|
||||||
}
|
}
|
||||||
emit('updateHeight', height);
|
emit('updateHeight', height);
|
||||||
|
Loading…
Reference in New Issue
Block a user