jquery - Distinguishing between the user scrolling and programmatically scrolling using Javascript -


i'm creating scrolling effect using jquery , i'm wondering if it's possible distinguish between user scrolling vs. programmatically scrolling.

i have this:

$('#element').on('scroll',function(e){     $('#element').stop(true); // stop previous scrolling animation     $('#element').animate({ // start new scrolling animation (maybe different speed, different direction, etc)         scrolltop:...     }); }); 

however, event triggered during every step of animation. how can tell if event triggered user or animation?

use variable determine when scrolling programmatically

example:

var programscrolling = false;  $('#element').on('scroll',function(e){     if (programscrolling) {         return;     }      $('#element').stop(true); // stop scrolling animation      programscrolling = true;      $('#element').animate({         scrolltop:...     });      programscrolling = false; }); 

not sure if want, concept should work.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -