Jump to content
Search Community

Image slide animation and clip-path issue

mapps-video test
Moderator Tag

Go to solution Solved by mapps-video,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi all, 

 

I am trying to do a image slide animation like here:

-> click Animate

 

All good except if the image is "transformed" the clip-path is not correct anymore. 

 

-> click Transform and then Animate

 

Now, questions:

  1. is there a different way to do this animation? 
  2. what is the problem with this clip-path? - or how can I fix it?

 

Thanks in advance,

Andrei

See the Pen gggdZO by klodoma (@klodoma) on CodePen

Link to comment
Share on other sites

Sorry, I don't know much about how clip-path works on transformed SVG elements. clip-path seems to have pretty poor support right now:

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/rect

 

Perhaps try an SVG <mask>. Here is a simple example: http://codepen.io/GreenSock/pen/jywVVq?editors=1010

 

Not sure how it will hold up to transforms. You may want to first find the masking / clipping technique that works the best cross-browser without any GSAP animation (check stackoverflow) and then see how that setup animates with GSAP. 

  • Like 2
Link to comment
Share on other sites

Hi mapps-video :)

 

Welcome to the GreenSock forum.

 

I'd agree with Carl here. clip-path is gonna be hit and miss right now. Your demo isn't working correctly for me in Firefox or Edge. I'd also recommend a mask. I'm wondering if you could just rotate the div that's wrapping the image rather than the image itself? Then the mask would go along for the ride.

 

Here's a fork of Carl's demo that rotates the SVG's parent div as the mask is animating.

 

See the Pen YNQpBm by PointC (@PointC) on CodePen

 

Hopefully that helps.

 

Happy tweening.

  • Like 2
Link to comment
Share on other sites

The question was actually about raphael, which I have no experience with.

Oh sure Mr. Smarty Pants. Actually take the time to read through the code and see which libraries are being used before answering the question.  :lol:

 

I have never tried Raphael so I'd be no help. Sorry.

  • Like 3
Link to comment
Share on other sites

  • Solution

Thank you all for your responses. 

 

Indeed mask seems to work better than clip. 

 

Here is my solution:

See the Pen OWgBVG by klodoma (@klodoma) on CodePen

 

The trick is: "create the mask" BEFORE the item transformation. It seems quite important, otherwise the getBBox() returns the transformed values. The item transformation is applied also to the mask itself.

  • Like 3
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...