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

140
Visualizações
e.preventDefault but allow (or replicate) natural scrolling on mobile

I'm making an application that will be used for touch and mouse devices where their respective events are handled slightly differently.

The standard practice for this is to use e.preventDefault() on touchstart because it fires before mousedown. preventDefault prevents the mousedown event from being called.

In my situation, I'm completely fine with disabling pretty much all 'default' actions of all touch/click events throughout the app apart from one aspect which is scrolling.

I have tried a few hacky workarounds to this by passing variables but it isn't quite robust.

I wonder what would be the best way to replicate the default movement of scrolling using e.preventDefault on mousestart and on mousemove (and thereby disabling it)? I can think of the standard way of simply listening to onscroll, calculating offset of mouse movement, and applying it to the element in question's scrollY, but that might take up battery due to the excessive javascript usage (though perhaps it isn't much different from native scrolling?). This is important since my app is an e-reader-like app. Also, I would have to manually replicate the 'flick' scroll too, which may not feel as natural.

Any thoughts would be appreciated!

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