I have setup a simple 1 page website, and when you click each menu item the page smoothly scrolls to that specific section. That part I have working fine...
Once the section loads, an image is displayed, and text slowly scrolls up over the image, which works absolutely fine on the first section (highest section).
Issue I am having when you click the second, third and fourth menu link, once the page moves to that section of the page, the content carries on scrolling up due to the sections above loading the scroll also.
This is the javascript I am using to load the text to scroll up:
$(document).ready(function() {
/* Every time the window is scrolled ... */
$(window).scroll( function(){
/* Check the location of each desired element */
$('.content-scroll').each( function(i){
var bottom_of_object = $(this).position().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* Adjust the "200" to either have a delay or that the content starts fading a bit before you reach it */
bottom_of_window = bottom_of_window + 800;
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object ){
$(this).animate({'margin-top':'0'},10000);
}
});
});
});
CSS:
.content-scroll { margin-top: 1000px; }
Can anyone recommend the best way to do this, so that when I click the second, third and fourth section link it would jump to that section, and the content above loads instantly, without the content having to scroll up?
Appreciate any feedback. Thank you
EDIT: Beforehand I input the code above for each link (.about-section
, services-section
etc), but realises I only needed to input it once.
Still, the content within scrolls up once the section is loaded.
Any feedback appreciated :)
EDIT 2: I have put together a test website, showing the scroll issue http://test.flixonstudios.co.uk - here you can see what I mean it clear detail.