4

I have the code:

$(window).bind('scroll', function() { //doing funny things here }); 

But I have to fire it a lot when it scrolls, like firefox does.
Firefox fires this multiple times when you scroll, but IE and Chrome fires it only once.
How can I force IE and Chrome to fire it more often in one scroll?
Or is there an alternative way for this?

9
  • 1
    try on instead of bind $(window).on('scroll', function() { ... }); Commented Oct 9, 2014 at 7:22
  • @VitorinoFernandes Doesn't work, still fires it only once in chrome and IE Commented Oct 9, 2014 at 7:23
  • I think your problem is that IE at least until v9 I believe does not scroll smoothly. Instead it jumps a couple pixels at once. Firefox scrolls very smooth and fires the event a couple times (since there are a lot of small jumps). IE does a single jump and fires only once. Commented Oct 9, 2014 at 7:41
  • @NoelWidmer I'm using the latest version of IE and Chrome, you're correct that they make a jump, and that is my problem, I am trying to find a solution for that and make it fire more often like firefox. Commented Oct 9, 2014 at 7:43
  • @Nick I never did this, but you could subscribe to the mousewheel callback in js and manually scroll through the page by adjusting the margin-top of an top-level container. Still, you would somehow have to prevent the default scrolling behaviour and call the scroll event from the browser manually. Are you looking for something like that? Commented Oct 9, 2014 at 7:49

2 Answers 2

1

That's a characteristic of the hardware, operating system and browser, nothing you can influence. Firefox has "smooth scrolling" by default, whereas other browsers just jump to the new position in fixed intervals. But then there are also operating system settings you can tune and also other input devices like touch screens and trackpads which have different characteristics.

Sign up to request clarification or add additional context in comments.

Comments

0

You can achieve this with this script. It creates an interval if there is none every time you scroll and then checks for when the scroll has stopped and terminates. Simply adjust the interval time, currently set to 1ms to what ever interval you require.

<script> var interval; $(window).bind('scroll', function() { if(interval == null) interval = setInterval(function(){/*funny stuff*/ console.log("scrolling :D")}, 1); clearTimeout( $.data( this, "scrollCheck" ) ); $.data( this, "scrollCheck", setTimeout(function() { console.log("stopped"); clearInterval(interval); interval = null; }, 250) ); }); </script> 

EDIT:
Optimised script.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.