Text length > transition completion?

I'd like to somehow translate text length (inferred from sourceRectAtTime) to transition completion.

The reason to do it this way is the text box has to be slanted, so simple scaling doesn't work (scaling messes up the slant angle). The blue textbox animates from right to left and reveals the white text.

I can't figure out how to have the first keyframe on the Job Textbox layer to be Zero and the second (last) to be inferred from the text lenght of the Job layer.

What you need is the linear() interpolation function. This basically lets you map one set of values to another. This is also helpful because any easing you apply to your original keys will translate to your new values. The expression would look something like what I'm posting below. I don't know exactly how your project is set up but hopefully this is enough to point you in the right direction. I'm also attaching a simple AEP file in case the expression does not make sense on its own. You can grab that here.

// this is the complicated bit.
// Basically this says:
// As the X value (value[0]) goes from the value of the first keyframe to the
// value of the second keyframe, interpolate between and return a value from
// the value of variable startWidth to the value of variable endWidth.
var w = linear(value[0],key(1).value[0],key(2).value[0],startWidth,endWidth);

My example above animated from the centre out. I've made a few adjustments to the project file to demonstrate a right-left animation. This basically involves setting the anchor point of the shape group to always be at the right edge of the type layer, and then offsetting the position enough to compensate. There's a new project here.

Just one more thing - when I type a longer text, the box and text scale from center. I need it to scale from right to left (same direction as the box grows in. In other words, I need the text and the box to be right-justified). I tried moving the anchor points but I can't really figure it out. Thank you very much.

In order to get the box to position correctly around the type, the anchor point has to be centered on the type. I placed an expression to keep the anchor point in the centre, but it does make the type behave as center-justified even if that's not how it's set in the paragraph panel. To fix, simply add the following expression to the position property on the type layer. All it does is forcibly offset the position of the type to make it appear as if it writes out from the left (it's actually writing from the center, but moving to the left at the same time so it seems like it's left justified).