I need to trigger my animation every time the site scrolls down. I’ve tried using webflows “Page Scroll Down” event and I put it on 1%. Figured every time the page scrolls down 1% my animation should trigger. At the moment it only triggers after the first scroll, unless I scroll up then down again.
My guess is webflows scroll event wont work so I’m looking into alternatives.
Anyone here got a script that allows me to trigger a “click” event every time the site scrolls down?
CJ Hersh is doing it in this example:
If anyone could simplify the code for me that would be lovely. So pretty much “When page scrolls down, click on this div”
Script by CJ Hersh:
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this,
args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
var onScroll = debounce(function(direction) {
if (direction == false) {
$("#w-slider-arrow-right").trigger('tap');
} else {
$("#w-slider-arrow-left").trigger('tap');
}
}, 200, true);
$('#slider').bind('wheel mousewheel', function(e) {
e.preventDefault();
var delta;
if (typeof event != 'undefined' && event.wheelDelta) {
delta = event.wheelDelta;
} else {
delta = -1 * e.originalEvent.deltaY;
}
onScroll(delta >= 0);
});