Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MacKentoch/4297f1605332b8d771a9df23e8219485 to your computer and use it in GitHub Desktop.

Select an option

Save MacKentoch/4297f1605332b8d771a9df23e8219485 to your computer and use it in GitHub Desktop.
// ReactJS:
<Motion style={{x: spring(this.state.open ? 400 : 0)}}>
{({x}) =>
<div style={styles.container}>
<div
style={
{
...styles.movingCube,
WebkitTransform: `translate3d(${x}px, 0, 0)`,
transform: `translate3d(${x}px, 0, 0)`
}
}
/>
</div>
}
</Motion>
// React Native:
<Motion style={{x: spring(this.state.open ? 270 : 0)}}>
{({x}) =>
<View style={styles.movingCubeContainer}>
<View
style={[
styles.movingCube,
{
transform: [{translateX: x}]
}
]
}
/>
</View>
}
</Motion>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment