Jump to content
Search Community

MorphSVG - How to reinstate an effect after it's use in a reusable function.

bromel test
Moderator Tag

Go to solution Solved by PointC,

Recommended Posts

Good evening EveryOne :)

I have been scratching my head on this one and thought I would be better to share the problem.

 

So I have been playing around with morphSVG and been blowing my mind🤯 with its features.

 

I am created a master timeline that utilises two functions to create my animation.

 

On the very first instance you will see a circle come onto the scene followed by two lines being drawn onto after the circles appearance.

In the second instance i then fade away both the lines and circle.

The animation is then repeated another two times using different coloured circles.

 

Now the issue that I have is that MorphSVG only works correctly on the very first run of the animation, after that the effect no longer works on the other two cycles.

 

I have tried to call a 'clearProps' method at the completion of the animation but this does not work, I am a bit stuck, so any pointers will be appreciated.

 

regards

 

Bromel

See the Pen vYVPEam by w9914420 (@w9914420) on CodePen

Link to comment
Share on other sites

Hey @PointC 

 

This is FANTASTIC!!! many thanks :)

 

just a very quick request, I was also wanting to get the lines to drop down by 20 on the Y axis, this is what i originally written:

function clearData(object) {
  let tl = gsap.timeline();
//
  tl.to(object, { y: 90, duration: 1, autoAlpha: 0 })
    .fromTo(
      "#para-long-line",
    {y: "0"},
      {
        y: "20",
        duration: 0.8,
        ease: "power4.out",
        autoAlpha: 0
      },
      "start+=.1"
    )
    .fromTo(
      "#para-short-line",
    {y: "0"},
      {
        y: "20",
        duration: 0.8,
        ease: "power4.out",
        autoAlpha: 0
      },
      "start"
    );

  return tl;
}

Unfortunately it kept on moving the lines down on every cycle, was not quite sure on weather my method or maths was at fault, any further pointers would be great, many thanks again :)

Link to comment
Share on other sites

Hi @PointC

 

Thank you for the quick reply, I have updated my original codepen, which now shows you the initial effect that I was trying to obtain, i thought best to separate my concerns without making it complicated. Has you can now see in the full version on the 'out' transition the 'para-lines' move down on the Y axis by 20. This works as expected on the first instance when the animation is ran, but after that it keeps on adding 20 units on each cycle.

 

 

I have tried using relative units and then clearing them on completion of each cycle, but this does not workScreenshot2023-05-25at15_48_48.png.94d2689a308528a299a7cb6b01e8da4e.png

This is the first cycle, notice the transform matrix values

 

Screenshot2023-05-25at15_51_43.png.797ba0d8e7aac078ff6693f22a2099aa.png

When I tried to clear the value it remained the same and just added another 20 units to the value.

 

I hope this clears things up and thanks again :)

 

Bromel

 

Edited by bromel
included example
Link to comment
Share on other sites

  • Solution

Yep - the relative value on each iteration is the culprit here. There are a few ways to solve it, but I think the easiest is just to set the lines back to 0 after they fade out. Add this to the end of the timeline in the clearData() function and you'll be good to go. You also won't need relative y values on the tweens in that function with this change. Just y:20 will work perfectly.

 

tl.set("#para-long-line, #para-short-line", { y: 0});

Happy tweening.

:)

 

  • Like 2
  • Thanks 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...