Currently, I am working on implementing a scroll function that dynamically moves elements based on the user's scrolling behavior. The code I have written works to some extent and successfully moves the elements.
However, my goal is to create a list of different functions that will move specific elements when the user scrolls past a certain div identified by its id or class.
I attempted to modify $("#pagelight2").scrollTop()
thinking it would solve the issue, but unfortunately, it did not work as expected.
I would greatly appreciate any guidance or suggestions you may have.
Thank you in advance for your help!
The updated code partially solves the problem, but it seems to be glitchy - especially when scrolling upwards. If anyone knows a more efficient way to achieve this functionality, please share your insights.
var $scrollingDiv = $(".Page3-PeopleWalkingDown");
var p = $("#pagedark3");
var offset = p.offset();
var top = offset.top;
$(window).scroll(function() {
var scrollval = $(window).scrollTop() - top;
if ($(window).scrollTop() > 1400) {
$scrollingDiv
.stop()
.animate({
"left": "-" + (scrollval) + "px"
});
} else
{
$scrollingDiv
.stop()
.animate({
"left": +(0) + "px"
});
}