Skip to content

Instantly share code, notes, and snippets.

@edwardsanchez
Created August 30, 2014 19:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardsanchez/6bd57e31edbaee37c6a6 to your computer and use it in GitHub Desktop.
Save edwardsanchez/6bd57e31edbaee37c6a6 to your computer and use it in GitHub Desktop.
Simulates string being typed with realistic delays
Name = new Layer width:400, x: 120, y:540, z:4, opacity:1, backgroundColor: "blue"
Name.html = ""
Name.style =
fontSize: '64px'
textAlign: 'center'
fontFamily: 'HelveticaNeue-Light'
lineHeight: '125px'
Name.on Events.TouchStart, ->
#Text to be typed
string = "Edward"
index = 0
typeCharacter = () ->
#Updating text, remove +"|" if you don't want cursor showing
Name.html = string[0..index]+"|"
index++
if index < string.length
#randomizes delay between keystrokes to simulate realistic typing
setTimeout typeCharacter, Math.random()*400
#adds 2 second delay to start
Utils.delay(2, typeCharacter)
@edwardsanchez
Copy link
Author

Would be nice if someone could add an animation for the cursor to blink continuously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment