Yep, I'd do exactly what @MindGamer recommended. Simple example:
function random(min, max) {
return min + Math.random() * (max - min);
}
function gotoRandomPlace() {
//notice the onComplete points back to this same function, so it'll keep going to random coordinates
TweenMax.to(...{x:random(-100, 100), y:random(-100, 100), onComplete:gotoRandomPlace});
}
gotoRandomPlace();
As for vw/vh units, those aren't supported on transforms because to maximize performance, GSAP bakes everything into matrix() or matrix3d() values which are always px-based (although it does support percentage-based values as well by prepending a translate() or translate3d()). You should be able to relatively easily convert vw/vh on your own, though, like:
//converts viewport units to pixels (like "50vw" or "20vh" into pixels)
function toPX(value) {
return parseFloat(value) / 100 * (/vh/gi.test(value) ? window.innerHeight : window.innerWidth);
}
//then, in your tween:
TweenMax.to(... {x:toPX("50vw"), y:toPX("20vw")});
The only caveat is that since the end result is in px, things won't shift if the window gets resized AFTER the tween finishes. But you could certainly use an onComplete to set those units directly, like element.style.transform = "translate(50vw, 20vh)"; if that's essential for your context.
Does that help?