Skip to content

Commit

Permalink
fix: fix type error
Browse files Browse the repository at this point in the history
  • Loading branch information
xuefei1313 committed Jan 17, 2025
1 parent e68b89b commit a4f9127
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/vstory-core/src/utils/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@ export interface ILayoutAttribute {
}

export function getLayoutFromWidget(w: Partial<IWidgetData> | IRect, character: ICharacter): Partial<ILayoutAttribute> {
let x = 'x' in w ? w.x : w.left;
let y = 'y' in w ? w.y : w.top;
let width = (w as any).width;
let height = (w as any).height;

if ('x1' in w && 'x2' in w && 'y1' in w && 'y2' in w) {
x = w.x1;
y = w.y1;
width = w.x2 - w.x1;
height = w.y2 - w.y1;
}
const x = 'x' in w ? w.x : 'left' in w ? w.left : 'x1' in w ? w.x1 : 0;
const y = 'y' in w ? w.y : 'top' in w ? w.top : 'y1' in w ? w.y1 : 0;
let width = 'width' in w ? w.width : 'x2' in w ? w.x2 - w.x1 : 0;
let height = 'height' in w ? w.height : 'y2' in w ? w.y2 - w.y1 : 0;

const stage = character.canvas.getStage();
if (!Number.isFinite(width)) {
Expand All @@ -35,8 +28,6 @@ export function getLayoutFromWidget(w: Partial<IWidgetData> | IRect, character:
if (!Number.isFinite(height)) {
height = stage.height - y - ((w as any).bottom ?? 0);
}
// const width = 'width' in w ? w.width : <number>(w as any).right - <number>w.left;
// const height = 'height' in w ? w.height : <number>(w as any).bottom - <number>w.top;

return {
x,
Expand Down

0 comments on commit a4f9127

Please sign in to comment.