Skip to content

Instantly share code, notes, and snippets.

@rorysmyth
Last active September 16, 2015 15:06
Show Gist options
  • Save rorysmyth/daf848f19862d9b10e94 to your computer and use it in GitHub Desktop.
Save rorysmyth/daf848f19862d9b10e94 to your computer and use it in GitHub Desktop.
class exports.Timeline
constructor: (@timelines) ->
@timeline = ""
@pointer = 0
@master = []
@makeTimelines()
@constructStrings()
makeTimelines: () ->
for timeline, i in @timelines
step =
layer: timeline[0]
duration: timeline[1]
properties: timeline[2]
delay: 0
ease: timeline[4]
offset = timeline[3]
@pointer = @pointer + step.duration + parseFloat offset
step.delay = @pointer - step.duration
@master.push step
constructStrings: () ->
animationStrings = ""
for timeline in @master
propertyString = ""
for property, value of timeline.properties
propertyString += "#{property}:#{value},"
jsString = "
Utils.delay(#{timeline.delay},function(){
return #{timeline.layer.name}.animate(
{
properties:{#{propertyString}},
time:#{timeline.duration},
curve:'#{timeline.ease}'
}
);
});"
@timeline += jsString
play: () ->
return @timeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment