Skip to content

Commit

Permalink
fix wrong position of calling onStart
Browse files Browse the repository at this point in the history
  • Loading branch information
Wang Zhongliang committed Jun 21, 2018
1 parent 6fb189c commit f5fbe1b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Spring.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export default class Spring extends React.Component {
immediate,
reset,
onFrame,
onStart,
onRest,
inject,
native,
Expand Down Expand Up @@ -174,7 +173,6 @@ export default class Spring extends React.Component {

entry.start = cb => {
if (entry.animation.__getValue() === toValue) return entry.onFinish(cb)
if (onStart) onStart()
controller(
entry.animation,
{ to: toValue, ...callProp(config, name) },
Expand All @@ -200,6 +198,8 @@ export default class Spring extends React.Component {
}

start() {
const { onStart } = this.props

let fn = () =>
this.getAnimations().forEach(animation => animation.start(resolve))
let resolve,
Expand All @@ -209,6 +209,8 @@ export default class Spring extends React.Component {
return (this.timeout = setTimeout(() => fn(), this.props.delay))
}

if (onStart) onStart()

fn()
return promise
}
Expand Down

0 comments on commit f5fbe1b

Please sign in to comment.