Skip to main content
Participant
August 10, 2021
Answered

Maintain Distance Between Multiple Text Layers

  • August 10, 2021
  • 1 reply
  • 2253 views

Hello Community,

I am creating a text carousel template where I would like text layers (up to 😎 to maintain the horizontal distance between each other if I change the source text.

 

So for example, if I were to change the text in the  "Step Cross Behind" or "Line Dance", I would like to be able to maintain that gap of space between the two without having to manually re-position it each time I need to change the text for a new carousel.

 

I am newer to expressions so any help would be greatly appreciated.  Please let me know if something like this is possible.  Thank you so much.

This topic has been closed for replies.
Correct answer Rick Gerard

You would automate that by having each set of words on a separate text layer and then use sourceRectAtTime() to figure the size of each text layer and add the required space. You would also tie the text layer position and the left value for each subsequent text layer into the calculations It could all be done with the position property of the text layers. Start with the leftmost text layer at the bottom then add this expression to the next layer above it.

src=thisComp.layer(index + 1);
srcWidth = src.sourceRectAtTime().width;
pad = 80 // distance between layers
newX = srcWidth + pad;
strtPos = src.position;

[strtPos[0] + newX, strtPos[1]]

If you wanted the top layer to be the words on the far left you would change the index + 1 to index - 1.

 

As long as all layers have the same paragraph setting they will line up 80 pixels apart.  All you have to do is position the master (far left) layer. 

1 reply

Rick GerardCommunity ExpertCorrect answer
Community Expert
August 10, 2021

You would automate that by having each set of words on a separate text layer and then use sourceRectAtTime() to figure the size of each text layer and add the required space. You would also tie the text layer position and the left value for each subsequent text layer into the calculations It could all be done with the position property of the text layers. Start with the leftmost text layer at the bottom then add this expression to the next layer above it.

src=thisComp.layer(index + 1);
srcWidth = src.sourceRectAtTime().width;
pad = 80 // distance between layers
newX = srcWidth + pad;
strtPos = src.position;

[strtPos[0] + newX, strtPos[1]]

If you wanted the top layer to be the words on the far left you would change the index + 1 to index - 1.

 

As long as all layers have the same paragraph setting they will line up 80 pixels apart.  All you have to do is position the master (far left) layer. 

Participant
August 10, 2021

This was extremely helpful.  Thank you so much Rick, it was exactly what I was looking for!