mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
show album name and play button on scroll down
This commit is contained in:
@@ -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();
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user