Skip to content

Instantly share code, notes, and snippets.

@magjac
Last active August 4, 2017 18:46
Show Gist options
  • Save magjac/1146ec566345eea83732425f11570bc8 to your computer and use it in GitHub Desktop.
Save magjac/1146ec566345eea83732425f11570bc8 to your computer and use it in GitHub Desktop.
D3 timer bug (?) 3
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<h1>Open the console and look for messages</h1>
<script src="//d3js.org/d3.v4.min.js"></script>
<script>
var n = 30000000;
console.time('delay1');
d3.transition()
.delay(500)
.duration(1000)
.on("start", function() {
console.timeEnd('delay1');
console.time('duration1');
})
.on("end", function() {
console.timeEnd('duration1');
console.time('delay2');
console.time('work');
for (i = 0; i < n; i++)
;
console.timeEnd('work');
})
.transition()
.delay(500)
.duration(1000)
.on("start", function() {
console.timeEnd('delay2');
console.time('duration2');
})
.on("end", function() {
console.timeEnd('duration2');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment