Skip to content

Instantly share code, notes, and snippets.

@criso
Created December 16, 2015 19:47
Show Gist options
  • Save criso/4629d80f94fe588e1262 to your computer and use it in GitHub Desktop.
Save criso/4629d80f94fe588e1262 to your computer and use it in GitHub Desktop.
const tabBtns = this.state.tabs.map((tab, index) => {
const tabKey = tab.key;
const style = this.buildMotionStyle(tabKey);
const isActive = this.props.selectedTabKey === tabKey;
return (
<Motion style={style} key={index}>
{
({scale, x, cursor, zIndex}) => {
return React.cloneElement(tab, {
key: tabKey,
onMouseDown: this._onMouseDown.bind(null, tabKey, x),
style: {
width : liWidth,
cursor : cursor,
transform : `translate3d(${x}px, 0, 0) scale(${scale})`,
WebkitTransform : `translate3d(${x}px, 0, 0) scale(${scale})`,
zIndex : isActive ? 300 : zIndex
},
isActive : isActive,
onClose : this._onCloseTab.bind(null, tabKey)
});
}
}
</Motion>
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment