FoundKey/packages/client/src/directives/appear.ts
Johann150 5b4c0ffdf3
client: fix some lints
Mostly focused on "@typescript-eslint/no-unused-vars" but also fixed some
other lints along the way.
2022-08-12 08:35:22 +02:00

23 lines
413 B
TypeScript

import { Directive } from 'vue';
export default {
mounted(src, binding) {
const fn = binding.value;
if (fn == null) return;
const observer = new IntersectionObserver(entries => {
if (entries.some(entry => entry.isIntersecting)) {
fn();
}
});
observer.observe(src);
src._observer_ = observer;
},
unmounted(src) {
if (src._observer_) src._observer_.disconnect();
},
} as Directive;