Below is the function which I use to automatically scroll on my practice site when a link is clicked.
$(function () {
$('a[href*="#"]').click(function () {
if(this.hash != "") {
TweenLite.to(window, 1.5, {scrollTo:{y:$(this.hash).position().top, autoKill:true}, ease: Power2.easeInOut});
} else {
TweenLite.to(window, 1.5, {scrollTo:{y:0, onAutoKill:autoKillFired}, ease: Power2.easeInOut});
}
return false;
});
});
function autoKillFired() {
alert("autoKill");
}
Is there a way to fire the autoKill function when the user scrolls the mouse wheel or uses a mouse pad to scroll?
Also I noticed that the autoKill function does not always fire when it should. For example if the user starts the scroll and then drags the scroll bar mid way through the animation, then it may or may not fire. Is this a known bug or is there a problem with my function? (This seems to occur for the browsers I have at my disposal. The latest versions of Google Chrome, Mozilla Firefox, Opera, and Internet Explorer . However when tested on codepen it seems to work all the time)