chenglou / chenglou/react-motion

onRest improvements?

Open
#342 4 comments 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

Possible to get the final styles from param in onRest function?
[Codepen link](http://codepen.io/linken/pen/PzGJwW?editors=0010)
This codepen example, there is no real way to know if the slider ended on the left side or right side if you press the button continuously.

How about implementing into TransitionMotion and StaggeredMotion?

``` javascript
...
({
key: item.key,
style: {width: item.size, height: item.size},
}))}
onRest={
(styleOnRestAll) => { console.log('all the animations are done, heres the final styles: ', styleOnRestAll) }
}
onRests={this.state.items.map(item => ({
key: item.key,
cb: (styleOnRest, styleOnRestAll) => { console.log(`do something after this ${item.key} is complete`, styleOnRest, styleOnRestAll); }
}))}>
{interpolatedStyles =>
// first render: a, b, c. Second: still a, b, c! Only last one's a, b.


{interpolatedStyles.map(config => {
return

})}

}

...
```

`onRests -> cb` would also be able to access styleOnRestAll in case it needs to do some stuff when a certain element animation value hits a sweet spot.

Maybe even add a new prop to the stylesObject, something like "isAnimating" or "isComplete"?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.