<div class="box green" id="green"></div>
<div class="box orange" id="orange"></div>
/* Global styles come from external css https://codepen.io/GreenSock/pen/JGaKdQ*/
//loads Draggable from: //cdnjs.cloudflare.com/ajax/libs/gsap/1.18.5/utils/Draggable.min.js
TweenLite.set("#orange", {x:500});
TweenLite.to("#orange", (Math.random() *3) + 0.5, {x:0, onUpdate:checkHit});
TweenLite.to("#green", (Math.random() *3) + 0.5, {x:500});
function checkHit() {
if (Draggable.hitTest("#orange", "#green")){
TweenMax.killTweensOf(".box");
TweenMax.to("body", 0.1, {backgroundColor:"red", repeat:3, yoyo:true});
}
}