I have made a site using locomotive scroll which worked perfectly until I uploaded to a live server. On the live server the elements sometimes bump into each other and then flicker and disappear and the footer is also cut off. It seems that the position of the elements isn't updating correctly so on scroll they have this glitch.
I'm thinking this must be a load issue, because sometimes it is fine and if I resize the browser that sometimes fixes it. Possibly I need to do an update() on the scroll once elements are loaded.
I looking to tweak the below code so that it checks to see if the page DOM has loaded but I'm not sure how to change it from timeout to checking page load.
function smooth() {
let scrollContainer = document.querySelector('your-selector');
scroll = new LocomotiveScroll({
el: scrollContainer,
smooth: true });
setTimeout(() => {
scroll.update();
}, 500);
}
You can use IntersectionObserver to update scroll as soon as document reach it's final height too.