diff --git a/src/index.ts b/src/index.ts index 89c5161..fdae9f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,3 @@ export * from './useTitle' export * from './useEvent' +export * from './useScrollRef' diff --git a/src/useScrollRef.ts b/src/useScrollRef.ts new file mode 100644 index 0000000..6afe0f4 --- /dev/null +++ b/src/useScrollRef.ts @@ -0,0 +1,15 @@ +import { ref, Ref } from 'vue' +import { useScroll, ScrollState } from './useScroll' + +interface IScrollState extends ScrollState { + target: Ref +} + +export function useScrollRef(): IScrollState { + const target: Ref = (ref(null) as unknown) as Ref + const state = useScroll(target) + return { + target, + ...state + } +}