-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>

5
  • 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? Commented Dec 4, 2016 at 21:47
  • dear i need to call the fuction if user is not scrolling Commented Dec 4, 2016 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 Commented Dec 4, 2016 at 21:49
  • please, i do't want if scrolling... i need if not scrolling with if else condition Commented Dec 4, 2016 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 Commented Dec 4, 2016 at 21:55

2 Answers 2

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.

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

Comments

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
})

1 Comment

.bind() has been deprecated, so its use was already discouraged.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.