chenglou / chenglou/react-motion

Need help for doing sequence of animation for single component

Open
#386 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
21.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use react-motion to move a component then scale it. But the following code seems to move horizontally back before scaling, does anyone can help for this?

```
const Demo = React.createClass({
getInitialState() {
return {open: false, sequenceId: 0}
},
handleMouseDown() {
this.setState({open: !this.state.open});
},
handleTouchStart(e) {
e.preventDefault();
this.handleMouseDown();
},
getStyles() {
return [
{
ms: {x: spring(this.state.open? 0 : -100)},
ans: '`rotate(${x}deg) translateX(-100px)`'
},
{
ms: {x: spring(this.state.open? 2 : 1)},
ans: '`scale(${x})`'
}
]
},
onRest () {
setTimeout(() => {
this.setState({
sequenceId: this.state.sequenceId + 1
});
}, 0);
},
render () {
// transform: eval(that.getStyles()[that.state.sequenceId].ans)
let that = this
return (



Toggle!!



{({x}) =>

}



)
}
})
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Demo component from the issue, focusing on getStyles, onRest, and the Motion render callback. Trace the sequenceId changes and transform expressions to understand the horizontal reversal. Done means the component moves first and scales afterward without the unintended movement back.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.