Hello everyone,
i started trying out GSAP a few days ago and I've been trying to create an animation involving moving a set of rectangles, but I ran into a bit of an obstacle. Imagine a row of lets say 10 rectangles (all elements in an svg). I want to swap the position of two of those. My implementation of this (which does not work properly) is the following function which calculates the distance between the elements and then uses gsap.to() to move them:
function swap(){