Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!