Let me explain what I'm trying to do. I have a function which controls scroll linked animations. I want to call it inside requestAnimationFrame()
, but I want to pass the window.pageYOffset
as the function's parameter. Now the code looks like this:
let wH = window.offsetHeight;
let ticking = false
function effects(wT, wH){
//animations using wT, wH
};
window.onresize = () => {
if (!ticking) {
wH = window.offsetHeight;
const wT = window.pageYOffset;
//I want to pass the wT, and wH to the rAF's parameter,
//which is the function above. How?
requestAnimationFrame(effects);
ticking = true;
}
}
window.onscroll = () => {
const wT = window.pageYOffset;
if (!ticking) {
//I want to pass the wT, and wH to the rAF's parameter,
//which is the function above. How?
requestAnimationFrame(effects);
ticking = true;
}
}