[ Launch: Tributary inlet ] 8af9ec9b7342ecec37a1 by Dan-Nolan
-
-
Save Dan-Nolan/8af9ec9b7342ecec37a1 to your computer and use it in GitHub Desktop.
Alphabet Transitions
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
{"description":"Alphabet Transitions","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/FS5q8SF.png"} |
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
var words = ["Mark Json", "Jark Mons", "Jark Mons", "Jerk Mang", "Jerk Mongult", "Jr Mongulty", "Dr Mongult", "Dr Meng", "Dr Who"] | |
var width = 960, | |
height = 500; | |
var svg = d3.select("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.append("g") | |
.attr("transform", "translate(32," + (height / 2) + ")"); | |
function update(data) { | |
// DATA JOIN | |
// Join new data with old elements, if any. | |
var text = svg.selectAll("text") | |
.data(data, function(d) { return d; }); | |
debugger; | |
// UPDATE | |
// Update old elements as needed. | |
text.attr("class", "update") | |
.transition() | |
.duration(750) | |
.attr("x", function(d, i) { return i * 32; }); | |
// ENTER | |
// Create new elements as needed. | |
text.enter().append("text") | |
.attr("class", "enter") | |
.attr("dy", ".35em") | |
.attr("y", -60) | |
.attr("x", function(d, i) { return i * 32; }) | |
.style("fill-opacity", 1e-6) | |
.text(function(d) { return d; }) | |
.transition() | |
.duration(750) | |
.attr("y", 0) | |
.style("fill-opacity", 1); | |
// EXIT | |
// Remove old elements as needed. | |
text.exit() | |
.attr("class", "exit") | |
.transition() | |
.duration(750) | |
.attr("y", 60) | |
.style("fill-opacity", 1e-6) | |
.remove(); | |
} | |
var i = 0; | |
update(words[i]); | |
setInterval(function() { | |
i++; | |
update(words[i % words.length].split("")); | |
}, 1500); |
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
text { | |
font: bold 48px monospace; | |
} | |
.enter { | |
fill: green; | |
} | |
.update { | |
fill: #333; | |
} | |
.exit { | |
fill: brown; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment