viewport-checker
viewport-checker copied to clipboard
Issues with Vue Directive
Hi, thanks for the plugin, i've been use it from the first version with jQuery. Now, i'm using the plugin with a Vue project with a custom directive but the 'attach' method only works once and i'd fixed including the scroll listener with the 'attach' method again.
Something like that:
let className = '.' + el.classList.value.split(' ').join('.');
const vpc = new ViewportChecker(className, {
offset: 400,
callbackFunction: (elem, action) => {
binding.value();
}
});
document.addEventListener('DOMContentLoaded', () => vpc.attach() );
document.addEventListener('scroll', () => vpc.attach() );
It works, but not always. Can you give a hand?
I figure it out if i have the browser console open (bottom) the function dont work.