MotionScript

@motion-script/core


@motion-script/core / TextSelection

Class: TextSelection

Defined in: nodes/text/text-selection.ts:65

A sub-range of a Text node's glyphs that can be animated independently. Returned by the node's selector methods (find, match, line, word, words, slice, filter).

Implements AnimationTarget so selection.to({ ... }, duration) plugs straight into the existing AnimationBuilder / parallel / sequence machinery — each tween writes resolved values into overrides, which the node reads when splitting its text into rendered pieces.

Example

yield* textRef().find("hello").to({ opacity: 0.5, y: -10 }, 1);

Implements

Constructors

Constructor

new TextSelection(node, ranges): TextSelection

Defined in: nodes/text/text-selection.ts:76

Parameters

node

Text

ranges

TextRange[]

Returns

TextSelection

Properties

node

readonly node: Text

Defined in: nodes/text/text-selection.ts:66


overrides

readonly overrides: SelectionOverrides

Defined in: nodes/text/text-selection.ts:74

Current resolved overrides for this selection. Numeric fields default to the node's current values (so a partial tween starts from the node's style); fill/stroke start as null (inherit) until tweened.


ranges

readonly ranges: TextRange[]

Defined in: nodes/text/text-selection.ts:67

Accessors

isIdentity

Get Signature

get isIdentity(): boolean

Defined in: nodes/text/text-selection.ts:94

True when this selection has no overrides differing from the node default.

Returns

boolean

Methods

_prepareStep()

_prepareStep(to, duration, easing?): TweenStepper

Defined in: nodes/text/text-selection.ts:123

Resolve one to() step into a flat TweenStepper. Numeric props (opacity/x/y/scale/rotation/fontWeight/letterSpacing) interpolate directly; fill/stroke resolve their target once and lerp via the shared fill/stroke array lerps — mirroring Node._prepareStep.

Parameters

to

Partial<TextSelectionProps>

duration

number

easing?

EasingFunction

Returns

TweenStepper

Implementation of

AnimationTarget._prepareStep


_toGen()

_toGen(to, duration, easing?): FrameGenerator

Defined in: nodes/text/text-selection.ts:173

Parameters

to

Partial<TextSelectionProps>

duration

number

easing?

EasingFunction

Returns

FrameGenerator

Implementation of

AnimationTarget._toGen


to()

to(to, duration, easing?): AnimationBuilder<TextSelectionProps>

Defined in: nodes/text/text-selection.ts:109

Parameters

to

Partial<TextSelectionProps>

duration

number

easing?

EasingFunction

Returns

AnimationBuilder<TextSelectionProps>