viewport-checker icon indicating copy to clipboard operation
viewport-checker copied to clipboard

Issues with Vue Directive

Open narcecl opened this issue 4 years ago • 1 comments

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?

narcecl avatar Jul 21 '20 17:07 narcecl

I figure it out if i have the browser console open (bottom) the function dont work.

narcecl avatar Jul 21 '20 17:07 narcecl