Skip to content

Instantly share code, notes, and snippets.

@Juriy
Created August 18, 2020 15:30
Show Gist options
  • Save Juriy/54e22a9209e7eef40664420f7e6c93ba to your computer and use it in GitHub Desktop.
Save Juriy/54e22a9209e7eef40664420f7e6c93ba to your computer and use it in GitHub Desktop.
// typewriter effect
// After Effects script
// based on work of @MotionHub and @Wesley Wiyadi
// set this variables to configure
const blinkSpeed = 2; // times per second
const speed = 15; // how fast characters will appear
const startAt = 0; // delay to start an effect
const cursorCharacter = '|'; // character to use as a cursor
const str = text.sourceText;
const cursorVisible = Math.round(time*blinkSpeed) % 2;
const cursor = cursorVisible ? ' ' : ;
const numCharacters = Math.floor(time * speed - startAt * speed);
numCharacters > 0 ? str.substr(0, numCharacters) + cursor : cursor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment