chore(Sticky): use tsx

This commit is contained in:
chenjiahan
2020-10-12 20:47:54 +08:00
parent f879b6d77a
commit c771604dec
2 changed files with 17 additions and 14 deletions
+7 -3
View File
@@ -9,7 +9,7 @@ import {
// @Experimental
export function useVisibilityChange(
target: Ref<Element>,
target: Ref<Element | undefined>,
onChange: (visible: boolean) => void
) {
// compatibility: https://caniuse.com/#feat=intersectionobserver
@@ -26,11 +26,15 @@ export function useVisibilityChange(
);
const observe = () => {
observer.observe(target.value);
if (target.value) {
observer.observe(target.value);
}
};
const unobserve = () => {
observer.unobserve(target.value);
if (target.value) {
observer.unobserve(target.value);
}
};
onMounted(observe);