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

fix: clipping behavior of children with transform #635

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

jozsefsallai
Copy link
Contributor

This PR updates the logic that's used to define the clipping of children relative to their parent element so that they render correctly when the parent has overflow: hidden and the child has a transform property. The new logic does the following:

  • if the current rect has a transform property, do not add a clip-path and a mask to the shape/image element, as that will be handled outside this element
    • images require special treatment, since these changes interfere with how the border radius is rendered for them, so we're defining a clip path for the border radius alone, which will be used on the image
  • if the current rect has a transform property, add a wrapper group element around the generated shape, which will have the original clip path and mask defined
    • also include the definition for the border radius clip path if it's an image
  • the functions used to build the content mask and the overflow will also include a transform attribute if the overflow is hidden and there is a transform definition

Also added unit tests for the behavior. All the previously defined tests pass. To my knowledge and based on my manual tests, these changes don't break existing behavior.

Before:

image

The magenta rects shouldn't overflow their parents.

After:

image

The clipping behavior is correct when the child has a transformation. This works even if the parent itself has a transformation.

Playground example: https://og-playground.vercel.app/?share=5VTBTsMwDP2VyKdNKlrZNJAi4MYPII69pIvbhmVJlKTrpqr_TrKIrR3jCBd6qe1nJ37vSelhozkChScu9oUixPmjxOe-jzEhXDgj2ZGSAiqJhwKyWB-GQr3E4GvoeuynwfgZ7YQXWkWIlU7L1uMI9tpQsszPucTKTwqd4L6hZJVfSg2Kugldq_WlVrLNtra6VTxe1DVicoveo62k7iLWCM5RncFIjpATvTHB7xRvrnJ7met1qnbTOMFGCwXililXabuLDW6L3WyZc6znCZDM4-wxN4csaGEO88loqS1H-8a4aN1Eq8SFkEVyaxHYhOhPnVuPxPlt626JeJdU_Ef2pj9koE10ywHt4UQF6H0euECiAPQhJhzLtgbqbYsZ4E5_iPejiQ-C705ZOKfSyr_uSuSpbcjAszJ0NCiDD9pKDsMn

Fixes #481

Copy link

vercel bot commented Sep 17, 2024

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

Name Status Preview Comments Updated (UTC)
satori-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 17, 2024 11:32pm

Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks!

@shuding shuding merged commit c55e4da into vercel:main Sep 17, 2024
9 checks passed
@jozsefsallai jozsefsallai deleted the bugfix/transform-clip-path branch September 17, 2024 23:37
Copy link

🎉 This PR is included in version 0.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

overflow:hidden not being respected when using transforms
2 participants