Jump to content
Search Community

animating masked SVG

celli 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

I am experimenting with masking with SVG+GSAP, and I am looking for the simplest cross-browser solution.

 

Here is the simplest solution I can see in the codePen, and it works in Safari and Chrome. In FireFox I see the mask, but it looks like GSAP doesn't animate it, and in IE9-10 I don't see the clip-path work, although it looks like IE 8+ supports the clip-path.

 

Using this as a starter, does anyone know of a way to tweak the masking to work in IE and FF ?

See the Pen LpEqJg by celli (@celli) on CodePen

Link to comment
Share on other sites

I'm still trying to find the best way to animate a mask, and I want to use the power of GSAP--so I found that snap SVG does a great job of allowing cross-browser masking and morphing of SVG shapes. I am mixing snap and GSAP, and I can get the ID of a snap created element, and control all of them with GSAP, which seems to work cross-browser--all except when I try and animate the MASK!

 

If you see this new codePen, I can animate all elements with GSAP, except for the mask which is "tl3" at the bottom of the JS code... any way to get the mask to animate with GSAP ?

 

See the Pen gapLjN by celli (@celli) on CodePen

Link to comment
Share on other sites

Hi,

 

As far as I remember, and I'm far from being a SVG expert, Snap does expose an API for the elements created with it, that can be accessed and Tweened with GSAP without too much problems.

 

Also Anthony created a Snap plugin based on the original RaphaelJS plugin, since Snap and Raphael were created by the same guy but the difference is browser support:

 

https://github.com/anthonygreco/GSAPSnapPlugin

 

Take a look at it and let us know how it works.

  • Like 2
Link to comment
Share on other sites

Thanks Rodrigo, I am now using the GSAPSnapPlugin, but I don't see it working. I can find all elements, and animate them all with GSAP, all except for my MASK! I am using the snapPlugin syntax like this, just replacing 'raphael' for 'snap' (it's the last line of code in the codePen: 

See the Pen gapLjN by celli (@celli) on CodePen

TweenLite.to("#maskee", 3, {snap:{x:100, y:100}, ease:Power1.easeInOut});
Link to comment
Share on other sites

Hi Celli,

 

The codepen link is broken :(

 

What you could do is create a console call to see what is being exposed in the mask and how it can be animated using GSAP. This is from Snap's docs:

 

http://snapsvg.io/docs/#Paper.mask

 

As I see it does exposes an x and y, so perhaps you might not need the snap:{} config object and just reference the mask directly:

TweenLite.to(myMask, 1, {x:300, y:300});

Sorry but I'm very short of free time now so I can't set up a working sample now. Hopefully this helps somehow.

  • Like 1
Link to comment
Share on other sites

Thanks Rodrigo, I think codePen was down! I updated the codePen--and I exposed the ID of the mask and I can animate it with SNAP but not GSAP, not sure why though. I put some comments in the JS to show snap animating the same element (mask) that I am trying to animate with GSAP. I'm going around in circles :) I've tried so many things, but I can't seem to target the mask. 

See the Pen gapLjN by celli (@celli) on CodePen

 

I love GSAP so much, I just really wish there was a GSAP mask plugin!

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