Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Maintain spacing between two text layers

Explorer ,
Apr 19, 2021 Apr 19, 2021

Hello dear Community

 

I am working on creating animation templates for our marketing department so they can easily produce visuals without much effort. I need to maintain the distance of the «Lorem Ipsum» text and the bullet point together with the «Dolor sit amet» text (see in attachement). I am not able to write expressions myself but I wanted to ask if anybody knows how I can make this happen. The hook is, that the text should always start the animation outside of the composition and not show even if the width gets larger. I would appreciate it so much if someone with actual expression knowledge could help me out with this. 

 

Thank you already

 

Josh Stacey

TOPICS
Expressions , How to
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2021 Apr 19, 2021

The usual sourceRectAtTime() expressions will work just fine. A simple web search will turn up plenty of examples, as it was everybody's favorite new feature two years ago and they felt they needed to do a tutorial on it. The rest is just basic math - width (of sourceRect A) plus position A is the position of sourceRect B and "outside the comp" is simply sourceRect B's width subtracted from the left edge (zero origin). The only real question is the time at which the rectangles get sampled to not interfere with your keyframed animation, but it seems you would simply use the time when the A segment has settled, so this would be key(3).time.

 

Mylenium

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 20, 2021 Apr 20, 2021

Thank you very much! I will try that 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 20, 2021 Apr 20, 2021

Here's how sourceRectAtTime() works.

 

sourceRectAtTime().width retiurns the width of a text layer or a shape layer not including the stroke width

sourceRectAtTime().height returns the height of a text layer or a shape layer not including the stroke width

sourceRectAtTime().top returns the distance from the baseline of a text layer

sourceRectAtTime().left returns the distance from tha anchor point of the text layer

 

You have to use a combination of all of these to compensate for any baseline shift or changes to paragraph justification. The text layer anchor point must be at 0, 0 for source rect at time to accurately adjust the position of other layers. 

 

I don't have time to work out the entire expression for you now but it will require references to the text layer position and all of the sourceRectAtTime() properties to set proper and consistent spacing for your project.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 21, 2021 Apr 21, 2021
LATEST

Maybe this will get you started. This will position any text layer 90 pixels to the right of any other text layer below it and still allow you to animate the Y position.  You could replace the pad with an expression control slider.

lyrOfst = thisLayer.sourceRectAtTime().left;
pad = 90;
mstr = thisComp.layer(index + 1);
mstrSize = mstr.sourceRectAtTime();
mstrWidth = mstrSize.width;
mstrLeft = mstrSize.left;
mstrPosX = mstr.position[0];
x = mstrPosX + mstrLeft + mstrWidth - lyrOfst + pad;
y = mstr.position[1] - (thisComp.height/2) + position[1];
[x, y]

With a little work, you could even get the entire move automated using the in points of the layers. I have about 50 Animation

Presets that work like that. Then animate a layer in and out based on the layer in and out points. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines