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

useSteps and animations #1229

Open
Manubi opened this issue Sep 20, 2022 · 6 comments
Open

useSteps and animations #1229

Manubi opened this issue Sep 20, 2022 · 6 comments

Comments

@Manubi
Copy link

Manubi commented Sep 20, 2022

Hi,
I am looking for the best way to do an animation.
I want to have two columns. Left are 4 bullet points on the right is one image.
CleanShot 2022-09-20 at 16 55 15
With the next step, (which I here need to trigger manually for the framer motion rectangle bg-red-200 animation) the rectangle moves down, the next text (bullet point) appears and a new image should appear on the right-hand side.
CleanShot 2022-09-20 at 16 57 26

Thanks for your help.

@fritz-c
Copy link
Contributor

fritz-c commented Sep 20, 2022

Here's an example that might give you some ideas of how to start. I'm not familiar with the animation library you are using, but I think there should be a way to work it into this setup.
https://codesandbox.io/s/synchronized-animations-example-spectacle-0ri8iv

@fritz-c
Copy link
Contributor

fritz-c commented Sep 20, 2022

The key part is wrapping the entire contents of the slide in the <Stepper> component so you can synchronize the appearance of the image and the bullet point. I had to put the first value as the fallback value for when the stepper value was undefined so it would have the behavior of showing the first bullet point+image from the start.

@Manubi
Copy link
Author

Manubi commented Sep 21, 2022

Thanks for the hints. That works with the image, but I still have a problem animating the background. I guess I would need the useSteps hook in order to execute it programmatically. The wanted effect is that the background of the text moves from the first item to the last item. And only the current item with highlighted background and the associated image is in the view. The former items don't have any background.

@Manubi
Copy link
Author

Manubi commented Sep 21, 2022

Another question. What is the priority prop for in the <Appear> component? It doesn't allow to let two items appear at the same time in the dom. Which I thought it would. meaning <Appear priority={1} /> and <Appear priority={1} should appear at the same time in the dom...

@fritz-c
Copy link
Contributor

fritz-c commented Sep 21, 2022

From the time I've spent with it, the priority prop just seems to rearrange the order of the appearance relative to its current order. There is no way to make two overlap without them depending on the same step via the workaround I showed. useSteps is helpful in that case because you don't have to wrap everything in a Stepper to get it done.

As for useSteps being useful for animations, I'm afraid it would give you no more flexibility than the Stepper workaround I showed. The step will change based on internal logic in either case, and your component has to judge how to animate based on that step change. You might be able to use a useEffect and refs to trigger animations imperatively, but React animation libraries (spectacle uses react-spring internally for the Appear component) might be a cleaner way to go about it.

@Manubi
Copy link
Author

Manubi commented Sep 21, 2022

thanks @fritz-c,
atm the useSteps hook doesn't work as it is not exported by the main package but I think the hook would help a lot as I would get access to the step value and could use that to trigger whatever animation I want to.

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