0

buenas tardes. Estoy haciendo una web y en el navegador los links funcionan correctamente, pero a la hora de verlo en tamaño móvil, al clickear los links me dejan mucho más abajo. No se porque sucede esto, en el tamaño grande, funciona perfecto y me deja exactamente en el h2 que quiero pero en el móvil no.

Pueden ver lo que sucede aquí: https://codepen.io/ZeR0ByTe/pen/wrbMRZ Clickear en "Nosotros" o "Galería" y luego probarlo en versión movil.

Espero que puedan ayudarme, muchas gracias por su tiempo!

1 respuesta 1

0

Finalmente un amigo me pudo resolver el problema, asi que comparto la solución por si a alguien más le sirve.

He quitado la librería JS de SmoothScroll y tambien el código para iniciarlo.

// SmoothScroll
        var scroll = new SmoothScroll('a[href*="#"]', {
        speed: 2000, 
        offset: 0, 
        easing: 'easeInOutQuart', // Easing pattern to use
     });

Y el correcto para que no suceda que en VERSIÓN MÓVIL vaya más abajo al clickear el link es este:

$('a[href*="#"]')
  .not('[href="#"]')
  .not('[href="#0"]')
  // Remove links that don't actually link to anything
  .click(function(event) {
    if (
      location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 
      && 
      location.hostname == this.hostname
    ) {
      // Figure out element to scroll to
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
      // Does a scroll target exist?
      if (target.length) {
        // Only prevent default if animation is actually gonna happen
        event.preventDefault();

        var scrollTop = target.offset().top - $('.sticky-top').height();

        $('html, body').animate({
          scrollTop: scrollTop
        }, 1000)
      }
    }
});

El codigo de arriba esta adaptado a lo que lo necesitaba yo, pero se baso en esto: https://css-tricks.com/snippets/jquery/smooth-scrolling/

Muchas gracias a todos igualmente!

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.