Hi from your example in https://react-move-docs.netlify.app/demos/simple
The first animate in that page, it's toggle the x value to either 200 or 0 when click.
How do I make it run another 200 instead of revert to 0 but base on click ?
If the inital position.left is 0 it become 200 on first click and 400 on second click and so on.
import React, { PureComponent } from 'react'
import { Animate } from 'react-move'
import { easeExpOut } from 'd3-ease'
const trackStyles = {
borderRadius: 4,
backgroundColor: 'rgba(255, 255, 255, 0.7)',
position: 'relative',
margin: '5px 3px 10px',
width: 250,
height: 50,
}
class Example extends PureComponent {
state = {
open: false,
}
handleClick = () => {
this.setState({ open: !this.state.open })
}
render() {
return (
<div>
<button
onClick={this.handleClick}
>
Toggle
</button>
<Animate
start={() => ({
x: 0,
})}
update={() => ({
x: [this.state.open ? 200 : 0],
timing: { duration: 750, ease: easeExpOut },
})}
>
{(state) => {
const { x } = state
return (
<div style={trackStyles}>
<div
style={{
position: 'absolute',
width: 50,
height: 50,
borderRadius: 4,
opacity: 0.7,
backgroundColor: '#ff69b4',
WebkitTransform: `translate3d(${x}px, 0, 0)`,
transform: `translate3d(${x}px, 0, 0)`,
}}
/>
</div>
)
}}
</Animate>
</div>
)
}
}
Hi from your example in https://react-move-docs.netlify.app/demos/simple
The first animate in that page, it's toggle the x value to either 200 or 0 when click.
How do I make it run another 200 instead of revert to 0 but base on click ?
If the inital position.left is 0 it become 200 on first click and 400 on second click and so on.