Finally solved the issues.
- Cleaned up my code adding clearfix to ensure the height of each section was reporting correctly.
Wrapped the funcitons animated on scroll inside Waypoint
$('#about').waypoint(function(direction){ $(document).scroll(function(){...}); });
I added a
window.onresize
function to recalculate the position on the relevant container to account for the reflow of content.window.onresize = function(){ tourPosition=$tours.offset().top; winH = window.innerHeight; };
To get a value to animate an elements from the left and right on scroll. I calculated scrollposition of the document + window height - position of the containing element.
scrollPos = $(this).scrollTop(); var posX = scrollPos - tourPosition + winH;
An offset was then added posX.
$('pic1').css({'left':posX-600});
$('pic2').css({'right':posX-800}); $('pic3').css({'left':posX-1200});