Answer the question
In order to leave comments, you need to log in
How to import js listener into VueJS component?
Hello, the question arose, there is throttle on listening to the scroll in the JS file, how can I pass it to App.vue, so that with its help the variable in date
throttle.js changes when scrolling:
function throttle(func, ms) {
let isThrottled = false;
function wrapper() {
if(isThrottled) {
return;
}
func.apply(this, arguments);
isThrottled = true;
setTimeout(function() {
isThrottled = false;
}, ms);
}
return wrapper;
}
window.addEventListener('scroll', throttle(function scroll(p) {
p = p + 1;
console.log(p);
}, 1000))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question