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']
|
||||
} satisfies SetupComponentOptions<IconsProps>;
|
||||
|
||||
type PathGenerator = (width: number, height: number) => Path2D;
|
||||
type PadFn = (
|
||||
divisor: number
|
||||
) => [left: number, right: number, top: number, bottom: number];
|
||||
type IconLoc = [
|
||||
x: number,
|
||||
y: number,
|
||||
@ -30,6 +26,9 @@ type IconLoc = [
|
||||
cx: 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 图标位置信息
|
||||
@ -51,7 +50,7 @@ function pad(
|
||||
width: number,
|
||||
height: number,
|
||||
divisor: number
|
||||
): [left: number, right: number, top: number, bottom: number] {
|
||||
): IconPad {
|
||||
return [
|
||||
x + width / divisor, // left
|
||||
x + width - width / divisor, // right
|
||||
|
@ -117,7 +117,7 @@ export const TextContent = defineComponent<
|
||||
TextContentEmits,
|
||||
keyof TextContentEmits
|
||||
>((props, { emit, expose }) => {
|
||||
const loc = ref<ElementLocator>(
|
||||
const loc = shallowRef<ElementLocator>(
|
||||
(props.loc?.slice() as ElementLocator) ?? []
|
||||
);
|
||||
|
||||
@ -160,7 +160,8 @@ export const TextContent = defineComponent<
|
||||
const updateLoc = () => {
|
||||
const height = getHeight();
|
||||
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];
|
||||
}
|
||||
emit('updateHeight', height);
|
||||
|
Loading…
Reference in New Issue
Block a user