Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
jQuery scroll through sections not working

I'm trying to implement a feature where if the user scrolls his mousewheel, it scrolls down to the next section, and when they scroll again, it scrolls to the next section again. Here is an example: https://dolomiti.lefayresorts.com/en

For some reason my code doesn't work. Here is my code:

        var justscrolled = false;
        
        function scrollUp(){
            if(scrollPos > 0){
                scrollPos--;
                scrollToSection(scrollPos);
            }
        }
        
        function scrollDown(){
            if(scrollPos < maxScroll){
                scrollPos++;
                scrollToSection(scrollPos);
            }
        }
        
        function scrollToSection(index){
            justscrolled = true;
            var to = $("#section" + index).offset().top;
            console.log(index);
            console.log(to);
            $(document).scrollTop(to);
        }
        
        $(window).bind('mousewheel', function(event) {
            if (event.originalEvent.wheelDelta >= 0) {
                if(justscrolled){
                    justscrolled = false;
                    console.log("A");
                }
                else{
                    scrollUp();
                    console.log("B");
                }
            }
            else {
                console.log("downscroll");
                if(justscrolled){
                    console.log("A");
                    justscrolled = false;
                    
                }
                else{
                    console.log("B");
                    scrollDown();
                    
                }
                
            }
        }); 

When I scroll, the console logs that the scroll function worked, and I can see some flickering on my page when I scroll, but for some reason it doesn't actually scroll to the different sections.

Here is the full html file that you can test and see that it is not working: https://pastebin.com/EuGS5G2a

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda