Last active
February 12, 2016 13:11
-
-
Save joshwcomeau/5b0f0f6c9642930d813e to your computer and use it in GitHub Desktop.
Animating the Unanimatable
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
class ArticleList extends Component { | |
componentWillReceiveProps() { | |
this.props.children.forEach( child => { | |
// Find the ref for this specific child. | |
const ref = this.refs[child.key] | |
// Look up the DOM node | |
const domNode = ReactDOM.findDOMNode( ref ); | |
// Calculate the bounding box | |
const boundingBox = domNode.getBoundingClientRect(); | |
// Store that box in the state, by its key. | |
this.setState({ | |
[child.key]: boundingBox | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment