Jump to content
Search Community

How to retain a svg path inside a container while rotating

shy_seagull test
Moderator Tag

Recommended Posts

Hi!

I have this SVG path that should be fitted into its frame when it’s being resized.

That is working fine when I use 

preserveAspectRatio="none"

but now my question is if I can also rotate the path using MouseY and still contain its boundaries to that of it’s parent. The Path should never overflow it’s parent container, if that makes sense.

 

The problem is I also want to morph the path at the same time using MouseX so I can’t rotate the path element itself but rather the group that is surrounding.

See the Pen vYVZNXd by lkssmnt-the-lessful (@lkssmnt-the-lessful) on CodePen

Link to comment
Share on other sites

Hi there,

 

There's certainly no easy way to approach something like this - preserveAspectRatio isn't aware of transforms. Does it have to be scaled up to fit the longest side of the viewport or could you make it smaller so it's longest side is never longer than the shortest viewport length?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...