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

136
Vistas
JS Help mouseup and Down

What I need:

How to do it with a key is fine, but with mouse is preferable. I need the website to scroll through itself while the mouse or key is down, and once released the site goes all they way back to the top. but if it reaches the Final section, the key/mouse down will no longer work.

What I have:

So the site is using gsap and scrolltriggers. I have touchable opacity :

HTML:

<a href="#top" class="touchableOpacity" id="TO"></a>

JS:

$("a[href='#top']").mouseup(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});

tls8In
.to("#TO",{top: -2000, duration:0.1})

It takes to top on mouse up and it is removed from viewport when the final section is entered. '''

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Hi! Try this code above. This code adds functionality to scroll html tag to element, which id is set in href attribute.

$('a[href*=#]:not([href=#])').click(function () {
  if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
    let target = $(this.hash);

    target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');

    if (target.length) {
      $('html,body').animate({ // which elements should be scrolled
        scrollTop: target.offset().top
      }, 1000); // animation time
      return false;
    }
  }
});

about 4 years ago · Juan Pablo Isaza Denunciar
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