I'm new to using expressions in after effects and I've also hardly touched Java before. However using some online tutorials and basic logic, I managed to create a lower thirds title graphic yesterday, the java is used to change it's position based on how much text is written inside. The title graphic bleeds off to the left of the screen, so when text is written on it, it moves left or right to match the length of text. I've included the code below.
What I want to do now is animate this, and this is where I'm struggling. Because I want to make this into a motion graphics template, I want the animation to work whatever text is has inside. The animation I want is for the graphic to simply slide in and slide out, however it's not as easy as this, because when there it not much text inside it, there is a delay before it appears on screen because it's position is further out of the frame. I'm not worried about consistent speed, I just want it to appear in at the same time as it has to match other animations.
Appreciate any help or ideas!
s =thisComp.layer("Header title");
x = s.sourceRectAtTime(time-s.inPoint,true).width;
subl =thisComp.layer("Sub title");
subt = subl.sourceRectAtTime(time-subl.inPoint,true).width;
text = Math.max(subt, x) -100;
max = 659.4;
m = Math.min(max, text);