Skip to content

Conversation

@PrecociouslyDigital
Copy link
Contributor

Hold no longer exists on Spring

Hold no longer exists on Spring
@drcmda drcmda merged commit fa1bfff into pmndrs:master Jul 29, 2018
@zachasme
Copy link
Contributor

zachasme commented Nov 2, 2018

Why was this removed? Is there a new way to achieve the effect?

@drcmda
Copy link
Member

drcmda commented Nov 2, 2018

I didn't know what it was tbh. Internals changed in 6.0, everything is controlled by a class called Controller, see: http://react-spring.surge.sh/manual, spring basically wraps around it. In the original animated library AnimatedValue and Animated.spring (which in react-spring was called AnimatedController) would control animations, which was problematic for performance reasons and it caused unwanted complexity.

From looking at old code (seems like this was removed long time ago actually ... 🤔)

        // Skip held animations
        if (hold && (hold === true || hold.indexOf(name) !== -1))
          return onFinish()

        AnimatedController(entry.animation, { toValue, ...config }, impl).start(
          props => props.finished && onFinish()
        )

to me it looks like it is the same as immediate but without jumping to end-state. I wonder though, wouldn't it be the same if you just don't set values/set them when it's time for them to change?

Could i see an example of the effect in action?

@drcmda
Copy link
Member

drcmda commented Nov 2, 2018

@PrecociouslyDigital API.md is a relic, could you remove the whole thing? Props are all extracted automatically from PropTypes in the official documentation now.

@zachasme
Copy link
Contributor

zachasme commented Nov 2, 2018

Discussion was in #48. I'll have to look into the new internals, it's been a while since I had the hold prop merged, perhaps it's no longer necessary.

@drcmda
Copy link
Member

drcmda commented Nov 2, 2018

Now i remember, thanks! I think this actually works out of the box now. http://react-spring.surge.sh/manual It can circumvent the render phase, for instance on mouse input.

https://codesandbox.io/s/ppxnl191zx?from-embed

This is because you can update a controller anywhere. This is very easy to do with hooks (and in that example you see how you can even re-use AnimatedValues in further springs. But theoretically this would also work with a generic <Spring /> which also uses that controller:

spring = React.createRef()
componentDidMount() {
  // This would animate views, but it won't cause a new render pass
  this.spring.current.controller.update({ ...newprops }, true)
}
render() {
  return (
    <Spring native ref={this.spring} ... >
      {props => <animated.div style={props} />

If there's something missing or if we need to make this easier we could discuss this in a separate issue.

@drcmda
Copy link
Member

drcmda commented Nov 2, 2018

Here's a proof of concept: https://codesandbox.io/embed/534v0v8pyx

It's not really as straight forward as hooks or imperative controller because it needs (to: {...}) but other than that it works. The only real difference is that now you can set props instead of relying on internals like AnimatedValue.

@PrecociouslyDigital PrecociouslyDigital mentioned this pull request Nov 4, 2018
@PrecociouslyDigital
Copy link
Contributor Author

@drcmda I added a pull request to remove the bit, but it has a trivial merge conflict I will resolve when I get home

szjemljanoj pushed a commit to szjemljanoj/react-spring that referenced this pull request Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants