Event Listeners #47
Replies: 11 comments 2 replies
-
@Neobii I would assume that it could help. import AnimateCC from "react-adobe-animate";
const App = () => {
const setAnimationObject = (obj) => {
obj.addEventListener('yourEvent', console.log)
}
return (
<AnimateCC
animationName="yourAnimationName"
getAnimationObject={setAnimationObject}
/>
);
}; |
Beta Was this translation helpful? Give feedback.
-
However I can see that you are using next.js. I am not sure but it could be tricky to setup it with next.js because of the SSR |
Beta Was this translation helpful? Give feedback.
-
Okay, good to know, I'll try it out here in a lil bit. My biggest use case is so far is managing state in react and animation without doing rerenders and avoiding race conditions or making sure all animations are complete. For this kind of work, do you think using events is okay or do you think using the new async/await is better than using event listeners? Eventually, if they ever add kinematics to animate or createjs, this will open animate up to doing more declarative based animations. It doesn't seem lottie files can use kinematics to predict transfer between states, like say something unity can do, so maybe they animate will have this eventually. For example, if an animation is playing and someone clicks a button, the current state of the animation will use kinematics to transition to the new state instead of manually making all the edge case animations, ie stopped to running, idle to running, collision to running etc. I'll see how far I can get! |
Beta Was this translation helpful? Give feedback.
-
Okay, I see that you are using |
Beta Was this translation helpful? Give feedback.
-
@Neobii the As to the async/await vs listeners to be honest I'm not really sure as to what do you mean. I couldn't figure out how does your code work as I am not familiar at all with zimjs and as so I don't really see where you'd like to change it. If you could provide me with an example code using react-adobe-animate, then I could probably help you a bit (codesandbox example would be the best) |
Beta Was this translation helpful? Give feedback.
-
Okay, cool, I'll try that out! Thanks for the quick reply! |
Beta Was this translation helpful? Give feedback.
-
Ah, I see you've added these
Works good! In nextjs, in the export file, I had to change my links to be relative to the public directory.
Also one other note... finding the Great stuff! |
Beta Was this translation helpful? Give feedback.
-
As far as next implementation... they would probably do something like this:
Instead of the content window trick, but maybe other people might want to try out this with ssr? Also with nextjs, there seems to be a race condition on when |
Beta Was this translation helpful? Give feedback.
-
@Neobii I'll try to look into this issue at the end of the week as I have had lots of work recently. However I am afraid that including it in the layout may be the only solution as far as the raw output from Animate goes. It's not really suited for this kind of job |
Beta Was this translation helpful? Give feedback.
-
I came across this article instead of using
Sorry, I'm still getting the feel of how github discussions work. |
Beta Was this translation helpful? Give feedback.
-
Looks like nextjs now has a I tried it out on some scripts so far, but some hit and miss with some of those creative frameworks with seeing |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to use some animate stuff inside react as well.
I'm wondering if you have an easier way to handle which animations are playing and having callbacks on certain frames bubble up to the react components.
I am also using zimjs
Beta Was this translation helpful? Give feedback.
All reactions