Last active
August 29, 2015 14:17
-
-
Save arnaudmolo/f701bfcabf76fa7e1df8 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
import React from 'react'; | |
export default React.createClass({ | |
animate(nextProps) { | |
const transition = d3 | |
.select(this.getDOMNode()) | |
.transition() | |
.duration(500); | |
Object.keys(nextProps).forEach(function(key) { | |
transition | |
.attr(key, nextProps[key]); | |
}); | |
}, | |
componentWillReceiveProps(nextProps) { | |
this.animate(nextProps); | |
}, | |
shouldComponentUpdate(nextProps, nextState) { | |
return false; | |
}, | |
render() { | |
return ( | |
<circle {...this.props} /> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could go a little further for .attr/.style animation, but the concept is easy to understand