Last active
December 19, 2015 01:59
-
-
Save walterm/5879588 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var interval = 6000; | |
var g = this.group; | |
var fall = true; | |
var callBack = function(){ | |
return function(){ | |
//Making it alternate between falling and going all the way back to the top instantaneously | |
if(fall){ | |
//Falling | |
g.transition().duration(interval).ease('linear').attr('transform', 'translate(0,3000)'); | |
fall = false; | |
}else { | |
//Resetting | |
g.transition().duration(0).attr('transform', 'translate(0,-1000)'); | |
fall = true; | |
interval = 6000; | |
} | |
d3.timer(callBack(),interval); | |
//Timer also executes the function until it returns true | |
return true; | |
}; | |
}; | |
//Timer executes the specified function after the specified number of seconds has passed | |
//In this case, I want it to start falling immediately | |
d3.timer(callBack(), 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment