I made a codepen to demo my issue and ended up solving it
function originFromChild(container, center){
const centerBox = center.getBBox();
const box = container.getBBox();
// get absolute center;
const centerX = centerBox.x + (centerBox.width / 2);
const centerY = centerBox.y + (centerBox.height / 2);
// then determine relative to container.
return ((centerX - box.x) / (box.width))*100 + '% '+
((centerY - box.y) / (box.height))*100 + '%';
}
// Usage
const tOrigin = originFromChild(document.getElementById('sun'), document.getElementById('sun-center'));
console.log(tOrigin);
TweenMax.to('#sun', 6, {rotation:"360", ease:Linear.easeNone, repeat:-1, transformOrigin: tOrigin});
The question then becomes.. is this a good approach? and is there anything already built in to do this? (also makes me wonder about other utilities I might not want to miss out on)
I'm completely new to GSAP and the first thing I tried to do turned out to be more complicated then I had bargained for haha.