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

Waiting before screenshot #74

Open
JavierM42 opened this issue Mar 16, 2022 · 6 comments
Open

Waiting before screenshot #74

JavierM42 opened this issue Mar 16, 2022 · 6 comments

Comments

@JavierM42
Copy link

We are having issues with components that have mount animations. Since we don't know how to wait for them to finish, our screenshots are slightly different every time.

Is it possible to solve it with beforeScreenshot?

@fwouts
Copy link
Owner

fwouts commented Mar 16, 2022

Hi @JavierM42, what kind of animations are you dealing with? If they're CSS, I'd recommend importing an extra CSS file that disables them. If you can share a code sample, that'd be appreciated!

@JavierM42
Copy link
Author

We're using Framer Motion.

If you try to screenshot something like this, the resulting screenshot never gets the same opacity.

<motion.div
  initial={{ opacity: 0 }}
  animate={{ opacity: 1 }}
  transition={{ duration: 1 }} // optional, default value is enough for it to be a problem
>
  Something
</motion.div>

We could add an environment variable to conditionally set duration: 0, but we'd have to do that on every animated component and pollute the codebase with specific behavior that's only for screenshots.

I guess that a better solution would be to add a delay before taking the screenshot, but I'm not sure if/how we can do that with Viteshot.

@fwouts
Copy link
Owner

fwouts commented Mar 16, 2022

Cheers for the extra context.

I can think of a couple of approaches:

If it works, the former would be better as it won't slow down your screenshots and wouldn't require extra boilerplate.

Let me know how you go.

@JavierM42
Copy link
Author

I tried the motion config yesterday, it only stops transforms that actually move elements (translateX, translateY, rotate, ...), opacity isn't affected.

I'll try the timeout tomorrow and get back to you, thanks!

@JavierM42
Copy link
Author

Timeout works great! Thanks a lot @fwouts

Awesome tool btw 🎉, I even wrote a blog post about it. It's been a massive improvement to our workflow.

@fwouts
Copy link
Owner

fwouts commented Mar 17, 2022

Awesome @JavierM42, thanks for the article!

I wonder if you've seen the -p flag? It should hopefully be able to replace your git-auto-commit-action step :)

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

No branches or pull requests

2 participants