show album name and play button on scroll down

This commit is contained in:
geoffrey45
2022-06-09 10:43:14 +03:00
parent 6aad05084f
commit 843a80f4a3
4 changed files with 51 additions and 12 deletions
+21
View File
@@ -0,0 +1,21 @@
import { ref } from "@vue/reactivity";
import { useIntersectionObserver } from "@vueuse/core";
import { Ref, watch } from "vue";
export default function useVisibility(
elem: Ref<HTMLElement>,
callback: () => void
) {
const visible = ref(false);
useIntersectionObserver(elem, ([{ isIntersecting }], observerElement) => {
visible.value = isIntersecting;
});
watch(
() => visible.value,
(newVal) => {
callback();
}
);
}