var rect = $('#moveimg')[0].getBoundingClientRect(); var mouse = {x: 0, y: 0, moved: false}; $("#moveimg").mousemove(function(e) { mouse.moved = true; mouse.x = e.clientX - rect.left; mouse.y = e.clientY - rect.top; }); // Ticker event will be called on every frame TweenLite.ticker.addEventListener("tick", function(){ if (mouse.moved){ parallaxIt(".sect1-img-left", -100); parallaxIt(".sect1-img-left-bottom", -80); parallaxIt(".sect1-img-right", -100); } mouse.moved = false; }); function parallaxIt(target, movement) { TweenMax.to(target, 0.5, { x: (mouse.x - rect.width / 2) / rect.width * movement, y: (mouse.y - rect.height / 2) / rect.height * movement }); } $(window).on('resize scroll', function(){ rect = $('#moveimg')[0].getBoundingClientRect(); })