'Built in' position eased animation expression requesting thisComp.width

Community Beginner ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

Hi guys,
I've hit the limit of my expression knowledge.
I've got multiple different sized comps and I want to be able to copy and paste a text layer which it's total x position movement is always 5% of the composition width (which changes between comps).
I'd then like to be able to control animation length with markers or similar.

I know I need to use thisComp.width but I'm not sure of the rest.
Any help would be greatly appreciated.

Thanks,
Tom

TOPICS
Expressions , Scripting

Views

58

Likes

Translate

Translate

Report

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 ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

Try this:

 

mov = 10; // percent of comp width
lyrW = sourceRectAtTime().width;
movFrms = 24; // number of frames for the move
t = time - inPoint;
tMin = 0;
tMax = tMin + mov * thisComp.frameDuration;
value1 = 0 - lyrW;
value2 = thisComp.width * mov * .01;
x = ease(t, tMin, tMax, value1, value2);
y = value[1];
[x, y]

 

If the text layer is Left Justified, it will move from the left edge of the frame until the left edge is at 10% of the comp frame width in 24 frames.  The move starts with the layer in-point, which is more efficient than using a layer marker because Animation Presets cannot add layer markers.

 

You can add an Expression Control Slider for the movFrms count in the first line of the expression. You can also add a slider to the mov variable to control the ending x position.

 

If you really wanted to fiddle with adding markers, you could change the "tMax" variable to read the in point of the layer plus the marker time, but I think adding a slider for move time is more efficient.

 

If you want the move to work with different paragraph justifications, modify the starting and ending position by using sourceRectAtTime().left. This is how that looks:

 

mov = 24; // move timing in frames
movD = 10; // end position in % of comp width
L = sourceRectAtTime();
LLeft = L.left;
LWidth = L.width;
t = time - inPoint;
tMin = 0;
tMax = tMin + mov * thisComp.frameDuration;
value1 = 0 - LWidth - LLeft;
value2 = thisComp.width * movD * .01;
x = ease(t, tMin, tMax, value1, value2 - LLeft);
y = value[1];
[x, y]

 

 

You had an idea that I turned into another one of my Animation Presets.

 

Likes

Translate

Translate

Report

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 Beginner ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

LATEST

Thanks so much for this Rick, it works well. Cheers.

Please could you help me change the ease to an 'expo' ease similar to 'ease and wizz'?

Thanks, Tom

Likes

Translate

Translate

Report

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