forked from idibidiart/d3-cssTransition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3-cssTransition.html
33 lines (31 loc) · 1.32 KB
/
d3-cssTransition.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="d3-cssTransition.js"></script>
<body>
<script>
// demo of d3 cssTransition plugin
var div = d3.select("body")
.append("div")
.style({position: 'absolute', left: '200px', top: '200px', width: '100px', height: '100px', background: 'red'})
.transition()
// using "end" allows d3 to cancel the cssTransition when the .transition is
// interrupted
.each("start" /* or end */, function() {
d3.select(this)
.cssTransition(
{
// now you can do any kind of hardware-accelerated transform
// and you don't have to create two transform strings and
// interpolate the numbers within using d3.interpolateString
// in styleTween or attrTween
transform: 'scale(2) rotate(45deg)'
},
{
duration: 5000,
complete: function() {alert('done')}
}
)
})
</script>
</body>