Skip to content

Commit be158f4

Browse files
authored
Merge pull request phaserjs#5194 from mikewesthad/types-fix-wordwrap
Update TextStyle to have jsdocs for word wrap related properties
2 parents 32db7ed + 8285bcf commit be158f4

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

src/gameobjects/text/TextStyle.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,58 @@ var TextStyle = new Class({
294294
*/
295295
this.baselineY;
296296

297+
/**
298+
* The maximum width of a line of text in pixels. Null means no line wrapping. Setting this
299+
* property directly will not re-run the word wrapping algorithm. To change the width and
300+
* re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}.
301+
*
302+
* @name Phaser.GameObjects.TextStyle#wordWrapWidth
303+
* @type {number | null}
304+
* @default null
305+
* @since 3.23.0
306+
*/
307+
this.wordWrapWidth;
308+
309+
/**
310+
* A custom function that will be responsible for wrapping the text. It will receive two
311+
* arguments: text (the string to wrap), textObject (this Text instance). It should return
312+
* the wrapped lines either as an array of lines or as a string with newline characters in
313+
* place to indicate where breaks should happen. Setting this directly will not re-run the
314+
* word wrapping algorithm. To change the callback and re-wrap, use
315+
* {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}.
316+
*
317+
* @name Phaser.GameObjects.TextStyle#wordWrapCallback
318+
* @type {TextStyleWordWrapCallback | null}
319+
* @default null
320+
* @since 3.23.0
321+
*/
322+
this.wordWrapCallback;
323+
324+
/**
325+
* The scope that will be applied when the wordWrapCallback is invoked. Setting this directly will not re-run the
326+
* word wrapping algorithm. To change the callback and re-wrap, use
327+
* {@link Phaser.GameObjects.TextStyle#setWordWrapCallback}.
328+
*
329+
* @name Phaser.GameObjects.TextStyle#wordWrapCallbackScope
330+
* @type {object | null}
331+
* @default null
332+
* @since 3.23.0
333+
*/
334+
this.wordWrapCallbackScope;
335+
336+
/**
337+
* Whether or not to use the advanced wrapping algorithm. If true, spaces are collapsed and
338+
* whitespace is trimmed from lines. If false, spaces and whitespace are left as is. Setting
339+
* this property directly will not re-run the word wrapping algorithm. To change the
340+
* advanced setting and re-wrap, use {@link Phaser.GameObjects.TextStyle#setWordWrapWidth}.
341+
*
342+
* @name Phaser.GameObjects.TextStyle#wordWrapUseAdvanced
343+
* @type {boolean}
344+
* @default false
345+
* @since 3.23.0
346+
*/
347+
this.wordWrapUseAdvanced;
348+
297349
/**
298350
* The font style, size and family.
299351
*

0 commit comments

Comments
 (0)