0

I am strongly suspecting that my abysmal scrolling performance on mobile devices is due to a multitude of events being fired by the elements being scrolled. Now - is there a handy way to generally prevent all of those events inside of the DOM element being scrolled from firing until scrolling is done? No mousenter, mouseleave, click, focus, active ... nothing ... until the user is done with scrolling?

Thanks for the help.

Fjonan
  • 41
  • 7
  • Check this link for similar question http://stackoverflow.com/questions/9144560/jquery-scroll-detect-when-user-stops-scrolling – Joel Worsham Oct 29 '13 at 15:54
  • Do you have evidence that mouse click and focus events are being fired on mobile devices in the first place? I'd be surprised if they were. – Christian Ternus Oct 29 '13 at 16:03
  • The event list was to clarify what I mean but I see now that it was not so wise. Yes you are right with click and focus. I am looking for a way to prevent any events from triggering while scrolling without having to manually track down every single eventlistener. Kind of a versaitle way that I could attach to any DOM element that stops anything going on while scrolling. Thanks to everyone who as already answered, I will look into all of that! – Fjonan Oct 29 '13 at 16:10

1 Answers1

0

It's unlikely that you would see performance issues just from the events firing, otherwise there would be performance issues on every page. More likely the code in those handlers is taking too long.

Probably you should debounce or throttle your event handlers as you bind them. I believe there are jQuery plugins available that provide similar functionality, or you can review the code of underscore and extract just the methods you need if you don't want to include the library.

Mike Edwards
  • 3,742
  • 17
  • 23