Jump to content
Search Community

Image slider with diagonal wipe - GSAP and SVG

namisuki test
Moderator Tag

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 There!!

 

I've been working with GSAP for a while and it is awesome in every way possible for web animations. As a newbie, I stumble when I go about implementing some complicated animations (atleast complicated for me). It would be of great help if any of the superheros (anyone who is of great help is a superhero, LOL) could help me figure out a way to implement a wipe image slider animation like the one in the below link but that looks like the image is wiped from a black board (diagonal wipe of the attached codepen).

 

slider animation: https://codyhouse.co/demo/animated-svg-image-slider/index.html

 

sliceimage codepen: (here the slices fade away, is there a way to make each slice wipe away one by one revealing the next image? like SVG masking or clip path)

See the Pen qadqxE by sgorneau (@sgorneau) on CodePen

 

Thank you! hope new year is going good for you.

 

Link to comment
Share on other sites

Hi @namisuki. That demo uses SVG and a <clipPath> to accomplish that effect. I don't have time at the moment to mock the whole thing up for you, but it basically boils down to: 

  • Instead of an <img>, use an <image> inside an <svg>. Well, one <image> for each image you've got, of course. All stacked. 
  • Define a <clipPath> that'll act as a mask (one for each image) and you can use a <path> or <polygon> in that which will have an angled edge to it. 
  • Animate the <path> "d" attribute with GSAP, or you could try animating the x position of it but I'm not positive all browsers will render that properly. And when I say animate the "d" attribute (or the "points" attribute of a <polyline>), I mean that you could have the beginning and the ending shapes and just copy that data into your tween. So if it starts at points="0,0 100,0 100,50 20,50", then you could tween to TweenMax.to(yourPolyline, 1, {attr:{points:"100,0 200,0, 200,50 120,50"}}); for example. 

I hope that helps! 

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Hi @GreenSock,

 

Thank you so much for your reply. I implemented the desired effect with your instructions. it came out pretty well in the below code pen. however when trying the effect diagonally, I kind of have hard time figuring out which 'd' value to animate( when i try to animate the 'M' value nothing happens). please refer the second code pen to see where i'm standing right now.

 

See the Pen zeKBpm by namisukichin (@namisukichin) on CodePen

 

is there a way to set the rotation the clippath of the above codepen so that the effect looks diagonal or animating the 'd' values are the only option?

 

diagonal try:

 

See the Pen aXmBqL by namisukichin (@namisukichin) on CodePen

 

Thank you.

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...