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

146
Vistas
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 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