<p>I have a lower third which resizes to the length of text. Now I want to make a overshoot effect. But.. I have no idea where to put the length of the text into the expression. </p>

<p>This is expression where the bar automatically resizes to the length of text including margin:</p>

<pre class="lang-js prettyprint-override"><code>s=thisComp.layer("Name"); // Text
x=s.sourceRectAtTime(time-s.inPoint,true).width; // Text width
y=content("Rectangle 1").content("Rectangle Path 1").size[1]; // Height
[x+10,y] // 10 = Margin on the right side.
</code></pre>

<p>This is overshoot expression:</p>

<pre class="lang-js prettyprint-override"><code>s=thisComp.layer("Name"); // Text
x=s.sourceRectAtTime(time-s.inPoint,true).width; // Text width
value[1] = content("Rectangle 1").content("Rectangle Path 1").size[1];// Set height.

freq = 1; // How many times should it overshoot?
decay = 15; // How far (in pixels)?

n = 0;
if (numKeys &gt; 0){
   n = nearestKey(time).index;
   if (key(n).time &gt; time) n--;
}
if (n &gt; 0){
   t = time - key(n).time;
   amp = velocityAtTime(key(n).time - .001);
   w = freq*Math.PI*2;
   value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
   value;
</code></pre>

<p>Now I have the [x] variable left and the 10 pixel margin. I've tried it to put it on any place, but it does not seem to work. </p>

<p>If I do: <code>value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w) - x - 10;</code>, the bar becomes smaller when the text becomes longer.</p>

<p><strong>The bar is a rectangular path.</strong></p>

<p>Does someone know how to resolve this? </p>

CC BY-SA 3.0
2015-08-05T15:28:02.303Z
you mean a bounce effect?
Alex
CC BY-SA 3.0
2015-08-05T19:00:33.793Z
Yes, this is a bounce effect. I followed  [this](http://www.motionscript.com/articles/bounce-and-overshoot.html#kf-overshoot)
user3625118
CC BY-SA 3.0
2015-08-06T15:21:49.487Z
Out of my zone of expertise, but perhaps precomp the resizer, and then bounce on the precomp?
Alex
CC BY-SA 3.0
2015-08-07T08:54:22.300Z
@Alex The problem now is, that the pre-comp can't bounce because it keeps the width of the composition. ( I pre-comped the bar that should bounce)
user3625118
CC BY-SA 3.0
2015-08-07T14:27:31.397Z
Could you add a simplified project file to this question?
p2or
CC BY-SA 3.0
2015-08-07T14:52:20.437Z
Sure, [here](http://puu.sh/jsPdG/ab068b8ac6.aep) you can find it
user3625118
CC BY-SA 3.0
2015-08-12T15:17:40.903Z
Any updates yet?
user3625118
CC BY-SA 3.0
2015-08-18T12:12:37.057Z
I think the problem here is that that bounce expression works by measuring the velocity at the keyframes on the size property, and adding an oscillation to it after the keyframes. But if the value is being driven by the length of the text then the keyframes are irrelevant. If you align the keyframes in the rectangles with the keyframes for the type reveal the expression works
stib
CC BY-SA 3.0
2015-08-18T16:00:44.107Z
Do you mean the text layer with "type reveal" ?
user3625118
<after-effects><after-effects-expressions>
Overshoot expression: Consider variable text width
user3625118
# Overshoot expression: Consider variable text width

(Asked by: username_0 on 2015-08-05)

I have a lower third which resizes to the length of text. Now I want to make a overshoot effect. But.. I have no idea where to put the length of the text into the expression. 
This is expression where the bar automatically resizes to the length of text including margin:
s=thisComp.layer("Name"); // Text
x=s.sourceRectAtTime(time-s.inPoint,true).width; // Text width
y=content("Rectangle 1").content("Rectangle Path 1").size[1]; // Height
[x+10,y] // 10 = Margin on the right side.

This is overshoot expression:
s=thisComp.layer("Name"); // Text
x=s.sourceRectAtTime(time-s.inPoint,true).width; // Text width
value[1] = content("Rectangle 1").content("Rectangle Path 1").size[1];// Set height.

freq = 1; // How many times should it overshoot?
decay = 15; // How far (in pixels)?

n = 0;
if (numKeys > 0){
   n = nearestKey(time).index;
   if (key(n).time > time) n--;
}
if (n > 0){
   t = time - key(n).time;
   amp = velocityAtTime(key(n).time - .001);
   w = freq*Math.PI*2;
   value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
   value;

Now I have the [x] variable left and the 10 pixel margin. I've tried it to put it on any place, but it does not seem to work. 
If I do: value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w) - x - 10;, the bar becomes smaller when the text becomes longer.
The bar is a rectangular path.
Does someone know how to resolve this?

**Tags:** after-effects, after-effects-expressions

> **Comments:**
> **username_1**: you mean a bounce effect?  
> **username_0**: Yes, this is a bounce effect. I followed  [this](http://www.motionscript.com/articles/bounce-and-overshoot.html#kf-overshoot)  
> **username_1**: Out of my zone of expertise, but perhaps precomp the resizer, and then bounce on the precomp?  
> **username_0**: @username_1 The problem now is, that the pre-comp can't bounce because it keeps the width of the composition. ( I pre-comped the bar that should bounce)  
> **username_2**: Could you add a simplified project file to this question?  
> **username_0**: Sure, [here](http://puu.sh/jsPdG/ab068b8ac6.aep) you can find it  
> **username_0**: Any updates yet?  
> **username_3**: I think the problem here is that that bounce expression works by measuring the velocity at the keyframes on the size property, and adding an oscillation to it after the keyframes. But if the value is being driven by the length of the text then the keyframes are irrelevant. If you align the keyframes in the rectangles with the keyframes for the type reveal the expression works  
> **username_0**: Do you mean the text layer with "type reveal" ?  

---

## 0 answers

