Hi there,
In this code, have have an object (aviaun_p2) moving around a blob once. What I can't do is to have the object back to its original position and size (center of stage) after the animation is completed. Are you able to see what I need to do to make this happen? What I am trying to do is have the animation work each time the object is clicked, but I want it to be back at its original position and size each time. This is what I have so far ....
const aviaun_p2 = zimify(this.aviaun_p2);
//const grid = new Grid();
//locate aviaun
aviaun_p2
.sca(.7)
.center()
//add the listener to the aviaun button
// Store the event listener reference
const animateListener = animate_aviaun_p2.bind(this);
// Add the click listener to trigger the animation
this.aviaun_p2.addEventListener("click", animateListener);
//the function that will run will be "animate_aviaun_p2"
//the data for the path of the animation
const data = [
[668.1, 139, 0, 0, -85.3, 5.3, 85.3, -5.3, "mirror"],
[1109.8, 310.8, 0, 0, 0, -50, 0, 50, "none"],
[640, 322.5, 0, 0, 50, 0, -50, 0, "mirror"],
[353.7, 320.9, 0, 0, -18.3, 39, 18.3, -39, "none"]
];
const path = new Blob({
points: data,
onTop: false,
stickColor: light
}).center();
path.visible = false;
//function to run the animation when the aviaun_p2 button is clicked
function animate_aviaun_p2() {
aviaun_p2
.sca(.7)
.center()
.centerReg()
.animate({
props: { path: path, orient: true, flip: true, zoom: [.2, 1.2] },
time: 6,
ease: "linear",
loop: false,
rewind: false,
drag: false,
startPaused: false
//onComplete: () => {
//
// // Remove the click listener after the animation is complete
// this.aviaun_p2.removeEventListener("click", animateListener);
// animationComplete = true;
// aviaun_p2.x=645;
// aviaun_p2.y=323;
//
//}
});
}
Thankyou.
Rod