How to Make Text Flow Up in After Effects
Usually text flows down, since that's how we read. But often times a UI will have the text flow up to maintain user focus, particularly in messaging applications.
After Effects lacks native functionality for this effect, so I created the Text Up feature within the Type script for text layer manipulation.
How It Works
Text Up applies an expression to the position property of your text layer. For each line break in your text the position of your text layer will shift up equal to the leading of the text.
You can animate typed text using the Typewriter+ function or preset.
The Expression Breakdown
The Text Up preset applies the expression automatically. For those interested in understanding the mechanics:
Step 1: Access the text
src = text.sourceText;
Step 2: Determine line height
breakHeight = src.style.leading;
Since auto-leading equals 120% of font size, the code handles this:
if (src.style.autoLeading) {
breakHeight = src.style.fontSize * 1.2;
} else {
breakHeight = src.style.leading;
}
Step 3: Count line breaks
breakCount = 0;
for (i = 0; i < src.length; i++) {
if (src.charAt(i) == "\r") {
breakCount++;
}
}
Step 4: Calculate new position
textUp = breakHeight * breakCount; posY = transform.position[1] - textUp;
Step 5: Return final coordinates
[transform.position[0],posY]
Each new line break automatically shifts the text upward by the calculated distance.