I am trying to adjust scroll speeds of some divs depending on if an other div (image-ul) is fully above the bottom of the webpage or not.
When the div "image-ul" moves above or below the bottom edge of the browser window it does change CSS, but the scroll speeds do not change upon scrolling or scaling of the window. I also want the scroll speeds to then change.
Only when (re)loading the page do the scroll speeds change according to where "image-ul" is in relation to the bottom egde of the browser window.
What am I doing wrong? Please see example here.
So, the goal is to have different scroll speeds for divs when div "image-ul" is fully above the bowser window's bottom edge, and different scroll speeds for those divs when div "image-ul" is NOT fully above the bowser window's bottom edge.
I am already achieving moving elements at different speeds, but, as my question states, I need the speeds to change depending on if div "image-ul" is fully above the browser window's bottom egde or not.
// Assign attribute specific "data-scroll-speed" to elements upon loading, resizing and scrolling of the webpage page. "if/else" is depending on if #image-ul is fully above the bottom edge of the browser window.
$(document).ready(function() {
$(window).on('load resize scroll', function() {
var WindowScrollTop = $(this).scrollTop(),
Div_one_top = $('#image-ul').offset().top,
Div_one_height = $('#image-ul').outerHeight(true),
Window_height = $(this).outerHeight(true);
if (WindowScrollTop + Window_height >= (Div_one_top + Div_one_height)) {
$('#sloganenglish').attr('data-scroll-speed', '4');
$('.slogan-a-line').attr('data-scroll-speed', '5');
$('.slogan-a-line').css('color', 'yellow');
} else {
$('#sloganenglish').attr('data-scroll-speed', '1');
$('.slogan-a-line').attr('data-scroll-speed', '1');
$('.slogan-a-line').css('color', 'red');
}
}).scroll();
});