How to check if an item is dragging

I want to check if an event occurs at the time the function is called. I have a function called when my custom scrollbar is dragged with .draggable () up and down, and I also have a function called when my container scrolls. The problem is that both of them start at the same time, which causes it to act incorrectly.

So my question is, how can I make an if if statement by checking if the scrollbar is being dragged so that I can stop it from executing the rest of the function code?

I do not ask if the element has an event β€œbound” to it or not, but if this event is fired at a certain moment.

Can I do it? Or do I need to do a different approach?

This is what my code looks like:

$('.container').scroll(function(){ //get the heights of the container and it contents and the difference //get the height of the scroll bar and it container and the difference //declare the top property of scroll bar from this info }); function scrolly() { //get the heights of the elements described above //declare the scrollTop of the container } $('.bar').draggable({ axis: 'y', containment: 'parent', drag: function() { scrolly(); } }); 
+8
jquery jquery-ui
source share
1 answer

Update

You can use this condition to find out if your panel is being dragged:

 if ($('.bar').is('.ui-draggable-dragging')) { return; // bar is being dragged } 
+13
source share

All Articles