Created
February 20, 2017 22:33
-
-
Save johnfmorton/d1993d869132f41943a835a175d5477a to your computer and use it in GitHub Desktop.
Merging a dynamic style with a predefined style in a React app
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 InfoPanel extends React.Component { | |
// a pre-defined style | |
scrollBarStyle = { | |
top: 0, | |
position: 'absolute', | |
width: '18px', | |
height: 54, | |
background: '#434344' | |
} | |
.... code excluded for clarity.... | |
render() { | |
return ( | |
<div className="scrollBarHolder" style={this.scrollBarHolderStyle}> | |
{/* NOTE TO SELF: I needed to merge the existing style with one updated property ... set my Motion in this case */} | |
<div className="scrollBar" style={ Object.assign( {}, this.scrollBarStyle, {transform: `translateY(${this.state.scrollBarOffset}px)`} )}></div> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment