Copy link to clipboard
Copied
 
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
Why not just make the number right-justified?
Copy link to clipboard
Copied
Why not just make the number right-justified?
Copy link to clipboard
Copied
My goodness, It worked hahhaha! I'm so embarrassed. Thank you very much. I guess I overcomplicated something so simple.
Copy link to clipboard
Copied
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:
Copy link to clipboard
Copied
Good. Is there a non have to pay way?
Copy link to clipboard
Copied
Pins & Boxes creates expressions. In principle, you can create all expressions yourself, but it is much more work then relying on the tool.