• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

112
Vistas
Slider to change slides on scroll

I am trying to implement the following setup:

When a user scrolls down my web page, I want scroll to function normally, until they reach a section where I have a slider. Once this section is in the viewport, the website should stop scrolling down the page, and the slider should scroll from slide 1 to slide 2. When the slides are finished, the page should continue to scroll as normal again.

The same should happen when the user is scrolling from bottom to top.

https://project-1-6122b1.webflow.io/slider

I have gotten it to mostly work on desktop, but unfortunately, it does not work on Mobile. The slides also just infinitely scroll. After slide 2, the page should cacrry on scrolling as normal.

<script>
    function debounce(func, wait, immediate) {
        var timeout;
        return function() {
            var context = this,
                args = arguments;
            var later = function() {
                timeout = null;
                if (!immediate) func.apply(context, args);
            };
            var callNow = immediate && !timeout;
            clearTimeout(timeout);
            timeout = setTimeout(later, wait);
            if (callNow) func.apply(context, args);
        };
    }

    var onScroll = debounce(function(direction) {
        if (direction == false) {
            $("#w-slider-arrow-right").trigger('tap');
        } else {
            $("#w-slider-arrow-left").trigger('tap');
        }
    }, 200, true);

    $('#slider').bind('wheel mousewheel', function(e) {
        e.preventDefault();
        var delta;
        if (typeof event != 'undefined' && event.wheelDelta) {
            delta = event.wheelDelta;
        } else {
            delta = -1 * e.originalEvent.deltaY;
        }
        onScroll(delta >= 0);
    });
</script>
about 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda