From 116a7842fd668de29e24732825a812c2a492e67a Mon Sep 17 00:00:00 2001 From: warxander Date: Wed, 29 Nov 2023 23:55:21 +0300 Subject: [PATCH] feat: Make `setNextFrameSpacing` parameters optional --- src/core/frame.ts | 12 ++++++++---- src/exports.ts | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/frame.ts b/src/core/frame.ts index 6c39fe1..96a2117 100644 --- a/src/core/frame.ts +++ b/src/core/frame.ts @@ -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; } @@ -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) { @@ -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 { diff --git a/src/exports.ts b/src/exports.ts index adb1d1e..62a3039 100644 --- a/src/exports.ts +++ b/src/exports.ts @@ -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); } /**