I have the following jQuery function that runs aTestEvent() when the user scrolls horizontally over 500 pixels:
jQuery(document).scroll(function(){ if(jQuery(this).scrollLeft() >= 500){ aTestEvent(); }});
Here's the problem: I want aTestEvent() to aTestEvent() once! However, every time the user scrolls back to the beginning of the page, and then again for 500 pixels, aTestEvent() fires again.
How can we configure the above code so that the trigger appears only for the first time , the user scrolls over 500 pixels?
source share