Skip to content

Commit 1a10ee1

Browse files
committed
Enhance caption positioning logic in media runtime
- Updated the caption positioning function to account for `Sequential` traits, ensuring proper handling of parent nodes that are not spatial constructs. - Improved the logic for retrieving the parent node, enhancing the accuracy of caption placement within the media runtime.
1 parent e0ff7ec commit 1a10ee1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/runtime/src/media/caption/position.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { store } from '../../world/store';
66
import { CaptionAlign } from '../../constants';
7-
import { Caption, Position, Computed, Host } from '../../traits';
7+
import { Caption, Position, Computed, Host, Sequential } from '../../traits';
88
import { getParentNode } from '../../queries/hierarchy';
99
import { resizeEntity } from '../../actions/resize';
1010

@@ -39,7 +39,12 @@ export function placeCaption(
3939
entity: Entity,
4040
preset: { width: number; height: number; x?: number; defaultAlign: CaptionAlign },
4141
): boolean {
42-
const parent = getParentNode(entity);
42+
// Sequences aren't spatial constructs; they mirror their parent's frame,
43+
// and only once the transform system has run — a fresh one still reads 0.
44+
let parent = getParentNode(entity);
45+
while (parent !== null && parent.has(Sequential)) {
46+
parent = getParentNode(parent);
47+
}
4348
if (parent === null) return false;
4449
const computed = store(world, Computed);
4550
const parentWidth = computed.width[parent.id()]!;

0 commit comments

Comments
 (0)