Giter Club home page Giter Club logo

Comments (8)

drcmda avatar drcmda commented on May 21, 2024 1

Seems to work, thanks for the help! https://codesandbox.io/embed/0qkll4y5nw 🙂 This is animating 60fps, no React/forceUpdate involved. Would be ready for react hooks as well.

I only needed this for an article explaining on how to write custom targets on the react-spring site. But if you like we could make this into a real target. All it needs is a better understanding on what objects to set.

from react-pixi-fiber.

michalochman avatar michalochman commented on May 21, 2024

@drcmda it is most certainly possible, it's how I work with most of my animations. Can you provide a sandbox where it returns null?

from react-pixi-fiber.

michalochman avatar michalochman commented on May 21, 2024

You can find working example in the examples folder if you want, using a ref on ParticleContainer which is a primitive:

ref={c => (this.particleContainer = c)}

There's also an example of spring animation using animated:

Animated.spring(this.state.rotation, { toValue: 1 }).start();

from react-pixi-fiber.

drcmda avatar drcmda commented on May 21, 2024

I was testing with the first demo on the frontpage (https://codesandbox.io/s/q913r72jo4)

and i'm going

function Bunny(props) {
  return (
    <Sprite
      ref={r => console.log(r)}

There's also an example of spring animation using animated

The AnimatedSprite in that example would still use forceUpdate though and render the animation out. But animated can be taught to animate natively pretty easy if there's a way to reach the inner lowlevel instance the outward component abstracts.

from react-pixi-fiber.

michalochman avatar michalochman commented on May 21, 2024

@drcmda the way you're getting ref in this example is by creating new function on each render (with arrow style). Because of that the previous ref callback is called with null first and only then the underlying instance is used to call the callback again, see comment on react issue by @gaearon. Should you just used ref={console.log} it would log null only once, during the first render when it doesn't have the instance yet.

If it's of any help to you, the way I was approaching this problem when I wanted to have ref callback created every time, was doing something like: ref={r => r !== null && console.log(r)}.


Regarding the AnimatedSprite example, you are right that the animated instance will use forceUpdate to render animation. However, this is just an example to show that it's possible to integrate animated into react-pixi-fiber and setNativeProps was not implemented as a part of this project. I planned to implement native animated target as a part of different library though, but that was never pressing.

from react-pixi-fiber.

drcmda avatar drcmda commented on May 21, 2024

in react-spring it would only be a couple if lines and react-pixi can animate natively, it is in theory driven by animated, though it's faster and easier to use. I'll run some tests and if i have something i'll post here. Thanks for clearing it up, it was indeed the loop - stupid of me to not thinking of that. 😓

from react-pixi-fiber.

michalochman avatar michalochman commented on May 21, 2024

Glad it worked @drcmda, that's one cool looking demo!

I'm definitely into getting a real target, this might be useful for many users. Let me know what you need to know and we can sort this out. I think I might even resume work on raw animated integration (by implementing setNativeProps).

from react-pixi-fiber.

michalochman avatar michalochman commented on May 21, 2024

#95 shows an example how to implement Animated that will skip React's forceUpdate.

from react-pixi-fiber.

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.