I am trying to move an SVG element into the foreground/ background during play and reverse.
I can get the element to move to the foreground at the start of the animation within the timeline, but I cannot get it to revert this change. I have tried using onReverseComplete on VSCode which works to an extent (some strange behaviour where it works randomly, but then will not work seemingly randomly), but on codepen onReverseComplete doesn't seem to work at all, despite using the same versions of GSAP.
Any clues or suggestions would be greatly appreciated.
function openCloseContactInfo() {
var contactAnimTlm = new TimelineMax({ paused: true, reversed: true });
contactAnimTlm.to(Note, { y: -100, onComplete: bringForward })
.to(CONTACTletters, { opacity: 0 }, 0)
.to(ContactInfo, { opacity: 1, onReverseComplete: bringBackward }, 0.5)
.to(Note, { scale: 3, transformOrigin: "50% 50%", y: 0 }, 0.5);
$(MailBody).click(function () {
contactAnimTlm.reversed() ? contactAnimTlm.play() : contactAnimTlm.reverse();
});
}
Thanks,
Adam