Skip to content

Instantly share code, notes, and snippets.

@djfumberger
Created March 7, 2016 23:58
Show Gist options
  • Save djfumberger/cf3066843fcfd3be7581 to your computer and use it in GitHub Desktop.
Save djfumberger/cf3066843fcfd3be7581 to your computer and use it in GitHub Desktop.
TextLayer = require 'TextLayer'
class module.exports extends Layer
dotSpacing = 12
dotSize = 12
dotDelay = 0.1
dotJump = 8
constructor: (options) ->
options ?= {}
super options
@.dotColor = options.dotColor
@.dotColor ?= "#000"
@.backgroundColor = ""
@.dots = [ @.createDot(0),
@.createDot(15),
@.createDot(30) ]
x = 0
delay = 0
for d in @.dots
d.x = x
@.animateDot(d, delay)
x += d.width + dotSpacing
delay += dotDelay
animateDot: (dot, delay) ->
if [email protected] || @.opacity == 0
return
obj = @
a = dot.animate
delay: delay
curvee: "spring(100,10,1)"
time: 0.2
properties:
opacity: 0.4
y: -dotJump
a.on Events.AnimationStop, ->
b = dot.animate
curvee: "spring(100,10,1)"
time: 0.2
properties:
opacity: 1.0
y: 0
b.on Events.AnimationEnd, ->
obj.animateDot(dot, 0.4)
createDot:(x) ->
new Layer
x: x
width: dotSize
height: dotSize
borderRadius: dotSize / 2
superLayer: @
backgroundColor: @.dotColor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment