Skip to content

Commit

Permalink
feat(useScrollRef): add useScrollRef
Browse files Browse the repository at this point in the history
  • Loading branch information
lmhcoding committed Sep 19, 2020
1 parent 9bc82da commit d963675
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './useTitle'
export * from './useEvent'
export * from './useScrollRef'
15 changes: 15 additions & 0 deletions src/useScrollRef.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ref, Ref } from 'vue'
import { useScroll, ScrollState } from './useScroll'

interface IScrollState extends ScrollState {
target: Ref<Element>
}

export function useScrollRef(): IScrollState {
const target: Ref<Element> = (ref(null) as unknown) as Ref<Element>
const state = useScroll(target)
return {
target,
...state
}
}

0 comments on commit d963675

Please sign in to comment.