mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 17:32:31 +00:00
feat: client-io-component.ts barebones functionality
This commit is contained in:
parent
d64d78fde8
commit
9ac1261662
@ -0,0 +1,24 @@
|
||||
import { defineComponent } from "vue"
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const data = ref(null);
|
||||
const isIntersecting = ref(false);
|
||||
const target = ref(null);
|
||||
let observer: Ref<IntersectionObserver | null> = ref(null)
|
||||
onMounted(() => {
|
||||
const observer = new IntersectionObserver(entries => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
isIntersecting.value = true;
|
||||
observer.unobserve(target.value);
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe(target.value);
|
||||
});
|
||||
|
||||
return {
|
||||
isIntersecting
|
||||
};
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user