This question was already asked here a long time ago:
Detect jquery event trigger by user or call by code
But it has never been answered conclusively (or m
Using @Tony's accepted answer and @DanielTonon's comment I came up with the following solution:
var animatedScroll = false;
var lastAnimatedScroll = false;
$(window).scroll(function(event){
lastAnimatedScroll = animatedScroll;
animatedScroll = $('html, body').is(':animated');
});
This seems to solve the issue mentioned whereby jquery removes the .is(':animated')
then scrolls one more pixel, which leads to .is(':animated')
ending on a false. By storing the second to last version of .is(':animated')
you can be (more) sure whether or not the scroll was an animated one or not.
When you want to know if the scroll was animated or not just check the lastAnimatedScroll
variable.
This has NOT been thoroughly tested by me but has been correct on many page refreshes so I will assume it works well enough.