GithubHelp home page GithubHelp logo

Where to handle Animations? about flux HOT 1 CLOSED

facebook avatar facebook commented on April 20, 2024
Where to handle Animations?

from flux.

Comments (1)

fisherwebdev avatar fisherwebdev commented on April 20, 2024

It's difficult to say without more context. This might be a situation where I would utilize the component's state, or I might move the state to the store. I think it would depend on the situation, and how the animation relates to the rest of the application state.

If you were to use the component's state, you could set up a requestAnimationFrame (rAF) in the component and call setState() with a new value on every cycle of the rAF. You could also do something similar in the store instead.

If you were using CSS transitions, you might let other parts of the application know you are currently animating (if needed) with a new action, store that state in the stores, and then when the animation is over, dispatch a new action to inform other parts of the app again.

The only complex animation I've done with React/Flux has been with a rAF in the store, and it was managing a very long animation -- over a minute in length.

For shorter, more UI-oriented things, I think I would keep the animation state in the components, and the more application-oriented state in the store. For example, I would have a value in the store like _isEditing. When _isEditing is true, the user should see an edit interface in a modal. When _isEditing first changes from false to true (checked in componentWillReceiveProps), the react component changes its state and starts the animation.

cc @sebmarkbage

from flux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.