Skip to content

Commit 6f6c98f

Browse files
feat(dialog): better text positioning and size
1 parent 357716d commit 6f6c98f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ AFRAME.registerComponent('dialog-popup', {
206206
value: value.substring(0, wrapCount),
207207
color,
208208
font,
209-
width,
210209
wrapCount,
211-
baseline: 'top'
210+
width: width - padding * 2,
211+
baseline: 'top',
212+
anchor: 'left'
212213
});
213214

214215
let y = height / 2 - padding;
@@ -217,7 +218,7 @@ AFRAME.registerComponent('dialog-popup', {
217218
}
218219

219220
title.setAttribute('position', {
220-
x: padding,
221+
x: -(width / 2) + padding,
221222
y,
222223
z: 0.01
223224
});
@@ -244,10 +245,11 @@ AFRAME.registerComponent('dialog-popup', {
244245
body.setAttribute('text', {
245246
value,
246247
color,
247-
width,
248248
font,
249249
wrapCount,
250-
baseline: 'top'
250+
width: width - padding * 2,
251+
baseline: 'top',
252+
anchor: 'left'
251253
});
252254

253255
let y = height / 2 - padding * 3;
@@ -256,7 +258,7 @@ AFRAME.registerComponent('dialog-popup', {
256258
}
257259

258260
body.setAttribute('position', {
259-
x: padding,
261+
x: -(width / 2) + padding,
260262
y,
261263
z: 0.01
262264
});

0 commit comments

Comments
 (0)