Last active
September 16, 2015 15:06
-
-
Save rorysmyth/daf848f19862d9b10e94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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