Skip to content

Commit

Permalink
feat: Make setNextFrameSpacing parameters optional
Browse files Browse the repository at this point in the history
  • Loading branch information
warxander committed Nov 29, 2023
1 parent c9127b2 commit 116a784
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/core/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FrameState {
flags = FrameFlags.None;
position: Vector2 | undefined = undefined;
scale: number | undefined = undefined;
spacing: Vector2 | undefined = undefined;
spacing: [number | undefined, number | undefined] | undefined = undefined;
styleId: string | undefined = undefined;
}

Expand Down Expand Up @@ -77,8 +77,8 @@ export class Frame {
Frame.nextState.position = new Vector2(x, y);
}

static setNextFrameSpacing(x: number, y: number) {
Frame.nextState.spacing = new Vector2(x, y);
static setNextFrameSpacing(x: number | undefined, y: number | undefined) {
Frame.nextState.spacing = [x, y];
}

static setNextFrameStyleId(id: string) {
Expand Down Expand Up @@ -114,7 +114,11 @@ export class Frame {
}

static getSpacing(): Vector2 {
return Frame.nextState.spacing ?? Frame.style.frame.itemSpacing;
if (Frame.nextState.spacing === undefined) return Frame.style.frame.itemSpacing;
return new Vector2(
Frame.nextState.spacing[0] ?? Frame.style.frame.itemSpacing.x,
Frame.nextState.spacing[1] ?? Frame.style.frame.itemSpacing.y
);
}

static isBackgroundDisabled(): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ export function setNextFramePosition(x: number, y: number) {
/**
* @category Frame
*/
export function setNextFrameSpacing(x: number, y: number) {
Frame.setNextFrameSpacing(x, y);
export function setNextFrameSpacing(x: number | null, y: number | null) {
Frame.setNextFrameSpacing(x ?? undefined, y ?? undefined);
}

/**
Expand Down

0 comments on commit 116a784

Please sign in to comment.