1

I'm doing a little jQuery plugin, and i'm confront a problem.

I read all internet without find a pertinent answer...

I have to say i don't want to prevent scroll at all, it's a little more complicated :

I have a system who scroll on the window with the jQuery function scrollTop(int y), but it's the same thing with the native javascript scrollTo(int y) (or scrollBy, indeed)

When those function are called, they trigger a 'scroll' event. And i don't want those functions to trigger this event, so i want to block it.

jQuery event.preventDefault(); doesn't work, obviously cause it block event action in event handlers function, so i just want this scroll event don't even be trigger.

I will be very thankful for help, cause i haven't any ideas how to do that.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Adam S
  • 1,021
  • 1
  • 14
  • 25
  • [Possible duplicate](http://stackoverflow.com/questions/1386696/make-scrollleft-scrolltop-changes-not-trigger-scroll-event?rq=1) – kei Jan 12 '13 at 01:22
  • Read http://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false – Libert Piou Piou Jan 12 '13 at 01:45
  • kei: Well i seen this question but it doesn't satisfy my needs : There is only one scroll (the scrollTo) who shoudn't trigger the event. The rest (keys, mousewheel and the others, and scrollTo triggered by other scripts too...) have to not conflict with. I'm looking for better option cause with this code, side scroll event trigger at the same time wouldn't work too... Piou piou : It's not about preventDefault, it's said on my post... – Adam S Jan 12 '13 at 01:46
  • Do u want to prevent default scroll when you mousewheel on specific div? – Pitchai P Jan 12 '13 at 06:13
  • No... i dont want prevent scroll. Isn't my post detailed enought ? I want scroll to work but no trigger 'scroll' event... But i start to thinks it's not possible to block an event trigger in JS... – Adam S Jan 12 '13 at 20:16
  • You might have to overwrite the native scrollTo function and add a prevent default in there somewhere to stop it, I'm looking into this too. – Philll_t Jun 27 '15 at 16:25

0 Answers0