Skip to content

Commit

Permalink
feat: PageLayout 组件增加 reachTop 事件
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Jun 27, 2024
1 parent 9a01975 commit 2ed6adc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/PageLayout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ withDefaults(
const emits = defineEmits<{
scroll: [Event]
reachTop: []
reachBottom: []
}>()
Expand All @@ -42,6 +43,9 @@ function handleMainScroll(e: Event) {
handleTabbarScroll()
handleBackTopScroll()
emits('scroll', e)
if ((e.target as HTMLElement).scrollTop === 0) {
emits('reachTop')
}
if (Math.ceil((e.target as HTMLElement).scrollTop + (e.target as HTMLElement).clientHeight) >= (e.target as HTMLElement).scrollHeight) {
emits('reachBottom')
}
Expand Down

0 comments on commit 2ed6adc

Please sign in to comment.