Skip to content

Commit 752ed25

Browse files
committed
1 parent f81409f commit 752ed25

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/Spring.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,26 @@ export default class Spring extends React.Component {
6161
}
6262

6363
state = { props: undefined }
64-
animations = {}
6564

6665
componentWillUnmount() {
6766
this.stop()
6867
}
6968

7069
componentWillMount() {
71-
this.updatePropsAsync(this.props)
70+
this.animations = {}
71+
this.mounting = true
72+
this.inject = this.props.inject && this.props.inject(this, this.props)
73+
if (this.inject) return
74+
this.updateProps(this.props)
7275
}
7376

7477
componentWillUpdate(props) {
75-
if (props.reset || shallowDiff(props.to, this.props.to))
76-
this.updatePropsAsync(props)
77-
}
78-
79-
updatePropsAsync(props) {
80-
if (props.inject) {
78+
if (props.inject && props.children !== this.props.children) {
8179
this.inject = props.inject(this, props)
8280
if (this.inject) return
8381
}
84-
this.updateProps(props)
82+
if (props.reset || shallowDiff(props.to, this.props.to))
83+
this.updateProps(props)
8584
}
8685

8786
updateProps(props, force = false, didInject = false) {
@@ -161,7 +160,7 @@ export default class Spring extends React.Component {
161160
this.animations[name].stopped = true
162161
if (this.getAnimations().every(a => a.stopped)) {
163162
const current = { ...this.props.from, ...this.props.to }
164-
if (onRest) onRest(current)
163+
if (onRest && !this.mounting) onRest(current)
165164
cb && typeof cb === 'function' && cb(current)
166165

167166
if (didInject) {
@@ -200,8 +199,6 @@ export default class Spring extends React.Component {
200199
}
201200

202201
start() {
203-
const { onStart } = this.props
204-
205202
let fn = () =>
206203
this.getAnimations().forEach(animation => animation.start(resolve))
207204
let resolve,
@@ -211,7 +208,7 @@ export default class Spring extends React.Component {
211208
return (this.timeout = setTimeout(() => fn(), this.props.delay))
212209
}
213210

214-
if (onStart) onStart()
211+
if (this.props.onStart) this.props.onStart()
215212

216213
fn()
217214
return promise
@@ -288,6 +285,7 @@ export default class Spring extends React.Component {
288285
componentDidMount() {
289286
this.updateToken = false
290287
this.start()
288+
this.mounting = false
291289
}
292290

293291
renderChildren(props, componentProps) {

src/Trail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default class Trail extends React.PureComponent {
6363
onRest={i === 0 ? onRest : null}
6464
key={keys[i]}
6565
{...props}
66-
delay={firstDelay}
66+
delay={firstDelay || undefined}
6767
attach={attachedHook}
6868
render={render && child}
6969
children={render ? children : child}

src/targets/web/fix-auto.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default function fixAuto(spring, props) {
2020
if (![...getValues(from), ...getValues(to)].some(check)) return
2121
// Fetch render v-dom
2222
const element = spring.renderChildren(props, spring.convertValues(props))
23+
// A spring can return undefined/null, check against that (#153)
24+
if (!element) return
2325
const elementStyles = element.props.style
2426

2527
// Return v.dom with injected ref

0 commit comments

Comments
 (0)