ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

**Search Bar Text expression**

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
ian cross
**Search Bar Text expression**
on Jul 4, 2020 at 7:34:37 am

Hi People,
So, I am trying to make an expression for text to resemble a search bar animation.
Similar to a 'typewriter' or 'wordprocessor' expression, except when it reaches a certain point in the text, the text starts to scrolls left as each letter appears.
Make sense?

Return to posts index

Filip Vandueren
Re: **Search Bar Text expression**
on Jul 4, 2020 at 12:26:25 pm

Ok, for starters; the animation you use for the type-on effect has to actually affect the size of the layer.
In other words: just using opacity to hide the letters won't work: you need to set the scale of the invisible letters to [0,0].

Depending on how you set up your animator, you might now see undesireable scaling up letters.
To combat that first: as the Range Selector's units use "Index", not percentage.
To the parameters you've animated for the scale animation (could be range Start, End, and/or Offset depending on your setup) add this expression:
OK, that will make sure no letters are animated fractionally: they will be either selected, or not, they will be invisible (scale 0) or not, nothing inbetween, so no funky scaling.

Thanks to these preceeding steps, we can make use of sourceRectAtTime(), to find the text's current width/height.
give the text-layer's anchorpoint this expression:


max_w would be the size in pixels of the box you want this to fit in.

Make sure to add a box of that size on top of the text to act as an Alpha trackmatte, so the characters that move off the left side get masked.

You might notice that on spaces, the text does not scoot 1 character to the left.
Indeed: Spaces don't add anything to the width.
A work-around could be to add dashes (or other characters that have the same width as a space) instead. If the background of your searchbox is a solid color, you can set the dashes to be that background color.
If that's a problem because of other design choices, you can use baseline-shift on the dashes to move them up and out of view. They will still add to the width, but they'll be masked of by the trackmatteā€¦

Return to posts index

ian cross
Re: **Search Bar Text expression**
on Jul 4, 2020 at 4:42:57 pm

Thanks Filip for your reply.
Much appreciated.
Ive added the typewrite behaviour to that text layer, and added the expression you supplied to the anchor point of the text layer, whilst amending the number of the box width in pixels. But the text doesnt shift left at any point?

Return to posts index

Filip Vandueren
Re: **Search Bar Text expression**
on Jul 4, 2020 at 4:51:07 pm

Does it give an error ?
What do you see as value for anchorPoint ?

If you enable "View -> Show Layer Controls", then do you see the bounding Box of the string growing as the text is revealed ?

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved