Skip to main content
BETHOTHEBOSS
Participating Frequently
October 17, 2023
Answered

Text Track expression

  • October 17, 2023
  • 2 replies
  • 1193 views

I'm not sure if someone has already posted this issue, but I have the following situation: I have two text layers, text 1 and text 2. Text 1 will have the number of days, and text 2 only says 'days ago.' I want to use an expression so that as the number increases, it shifts to the left and doesn't overlap. In this example, I'm changing the values from a SourceText in Essentials Graphics.

So, I used this expression, and it creates the desired shift, but the issue is that it animates the shift. I want the shift to occur directly from the SourceText in Essentials Graphics, and I want to be able to adjust the shift because I'll make it very large.

// Get the width of the text
w = thisLayer.sourceRectAtTime().width;

// Get the value from the source text
t = parseInt(thisLayer.text.sourceText);

// Define initial and final values for the number
start = 0;
end = 1;

// Define a duration for the animation in seconds
duration = 2;

// Calculate the text offset based on time
offset = linear(time, 0, duration, start * w, end * w);

// Return the original position minus the offset
value - [offset, 0];

the video of the expression running

This topic has been closed for replies.
Correct answer Dan Ebberts

Why not just make the number right-justified? 

2 replies

Mathias Moehl
Community Expert
October 18, 2023

In these situations, my extension Pins & Boxes is also very helpful.

If you want the "d ago" to move to the right, when the number grows, you could just create a pin for the right edge of the number layer and then parent the "d ago" text to it.

In this example, the small text is parented to the pin at the lower right corner of the bigger text:

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
New Participant
February 18, 2024

Good. Is there a non have to pay way?

Mathias Moehl
Community Expert
February 18, 2024

Pins & Boxes creates expressions. In principle, you can create all expressions yourself, but it is much more work then relying on the tool.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
October 17, 2023

Why not just make the number right-justified? 

BETHOTHEBOSS
Participating Frequently
October 17, 2023

My goodness, It worked hahhaha! I'm so embarrassed. Thank you very much. I guess I overcomplicated something so simple.