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

Add __experimental_sequenceProp to studio.transaction() #449

Closed
wants to merge 1 commit into from

Conversation

akre54
Copy link
Contributor

@akre54 akre54 commented Sep 16, 2023

I want the ability to programmatically add keyframes to a sequence, but it looks like the best way to do this is to use transaction(({set}) => {}). Unfortunately set doesn't create a Track from an unsequenced prop.

So let's say I have some data I want to turn into keyframes.

studio.transaction(({ set, unset }) => {
  const pos = sequence.position
  for (const keyframe of sequence.__experimental_getKeyframes(obj.props.x)) {
    sequence.position = keyframe.position
    unset(obj.props.x)
  }
  for (const {time, value} of data) {
    sequence.position = time
    set(obj.props.x, value)
  }
  sequence.position = pos
})

Currently, on main, If obj.props.x isn't already sequenced (i.e. manually from the Studio UI) then set will just set the static prop, which isn't what we want here. This pull allows you to at least tell Studio that you want to sequence the property.

@vimlesh1975 has some code that he posted to Discord that loops over all keyframes and unsets their value at the given time, but it would be really nice to be able to clear all keyframes for the initial track data, and ensure that the track is sequenced ahead of time.

See also #411

Ideally I'd like something like:

sequence.clearKeyframes(obj.props.x)
sequence.setKeyframeAtTime(obj.props.x, time, val)

But in the meantime at least this fixes the ambiguity of whether you want to set a static prop or a sequenced prop.

@vercel
Copy link

vercel bot commented Sep 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
theatre-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2023 3:17pm

@akre54
Copy link
Contributor Author

akre54 commented Sep 16, 2023

Changed to draft. getArrayOfValidSequenceTracks (called by set, from getMapOfValidSequenceTracks_forStudio and createTransactionPrivateApi) returns empty, so this needs to be fixed first

@AriaMinaei
Copy link
Member

Hi @akre54, this one is merged via 74b68c8. Feel free to send PRs for these as well 🙏

sequence.clearKeyframes(obj.props.x)
sequence.setKeyframeAtTime(obj.props.x, time, val)

@AriaMinaei AriaMinaei marked this pull request as ready for review October 9, 2023 15:12
@AriaMinaei AriaMinaei closed this Oct 9, 2023
@akre54
Copy link
Contributor Author

akre54 commented Dec 6, 2023

Hey @AriaMinaei any hope for this to be released soon? I have a feature that deals a lot with editing the timeline. Thanks! 🙏

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.

2 participants