Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the keyframes on state update #84

Open
tjebbemarchand opened this issue Feb 8, 2023 · 2 comments
Open

Update the keyframes on state update #84

tjebbemarchand opened this issue Feb 8, 2023 · 2 comments

Comments

@tjebbemarchand
Copy link

Environments

  • Framework name: ReactJS
  • Framework version: 18.1.0
  • Moveable Component version: 0.39.2
  • Scene Component version: 1.1.0
  • Testable Address(optional):

Description

We have build an application sort of like Figma, where you can create and drag layers around. We can give those layers some styling. And also, we can create animations on those layers. For this, we are creating keyframes and passing that to the Scene React component.

{ ".rectangle_OvnRKtiTq.halfpage": { "0": { "visibility": "visible", "transform": "translate(38px, 197px)" }, "5": { "visibility": "visible" }, "options": { "easing": "linear" } } }

But in order for this to work properly, we have to pass a key prop and update that every state change (so every time we drag a layer), so the Scene component will remount itself. This works, but then the Scene component and all of its children, including the layers, will also remount. This gives a flickering result to the layers because it has to load in the image and video layers as well.

If i remove the key prop, then the flickering goes away, but then the animations doesn’t update properly.

Is there a way to update the Scene component with the new keyframes without remounting? Or does Scene not support this? Does it only read the keyframes on componentDidMount and not on componentDidUpdate?

I hoped I explained it correctly. Thanks in advance for your response.

@daybrush
Copy link
Owner

daybrush commented Feb 8, 2023

@tjebbemarchand

Unfortunately, only in mount.

Dynamic options are not yet supported.

For dynamic updates, use the set function.

const {
   set
} = useScene or useSceneItem or useFrame


set({ ".rectangle_OvnRKtiTq.halfpage": { "0": { "visibility": "visible", "transform": "translate(38px, 197px)" }, "5": { "visibility": "visible" }, "options": { "easing": "linear" } } })

@tjebbemarchand
Copy link
Author

@daybrush

Thank you for your answer! I will look into this probably tomorrow and see if your suggestion works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants