-1

how to call javaScript function if user is not scrolling a div with id scrollingDiv. this is how i thought

function isScrolling() {
  if(<<isScrollingDiv>>) { 
    alert('Scrolling');
  } else {
    userNotScrolling();
}
isScrolling();
<div style="overflow:scroll" id="scrollingDiv">SomeContent</div>
br3t
  • 1,646
  • 2
  • 20
  • 27
Das
  • 1
  • 2
  • What exactly do you want? In which moment it should check scrolling? What will happen, if after check it'll run `userNotScrolling` and then user will scroll div? – br3t Dec 04 '16 at 21:47
  • dear i need to call the fuction if user is not scrolling – Das Dec 04 '16 at 21:47
  • i need to scroll the user bottom of div. i can do that but at first i need to check is user is scrolling. so i need to check if user is scrolling if no then i will call the function where the scrollbar set to bottm – Das Dec 04 '16 at 21:49
  • please, i do't want if scrolling... i need if not scrolling with if else condition – Das Dec 04 '16 at 21:54
  • Just create variable `isScrollingDiv = false`; set it to `true`, if user scroll div (you can use code by @Goliadkin); then check this variable in your `isScrolling` – br3t Dec 04 '16 at 21:55

2 Answers2

0

Check jQuery's on functionality.

You could do something like this:

$('#scrollingDiv').on('scroll', function() {
    //do something while the user is scrolling the div
})
GMaiolo
  • 4,207
  • 1
  • 21
  • 37
0

Since you're using jquery you could use scroll event like :

$('#scrollingDiv').on('scroll', function() {
     console.log('User scrolling the div');
})

or also :

$('#scrollingDiv').scroll(function() {
     console.log('User scrolling the div');
});

Hope this helps.

Zakaria Acharki
  • 66,747
  • 15
  • 75
  • 101