Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda