File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
src/ui/components/FaScrollArea Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ const props = withDefaults(
2525 },
2626)
2727
28+ const emits = defineEmits <{
29+ onScroll: [Event ]
30+ }>()
31+
2832const scrollAreaRef = useTemplateRef (' scrollAreaRef' )
2933
3034const arrivedState = ref <{
@@ -46,6 +50,10 @@ const showMaskEnd = computed(() => {
4650 return ! arrivedState .value ?.bottom
4751})
4852
53+ function onScroll(event : Event ) {
54+ emits (' onScroll' , event )
55+ }
56+
4957function onWheel(event : WheelEvent ) {
5058 if (props .horizontal ) {
5159 scrollAreaRef .value ?.el ?.viewportElement ?.scrollBy ({
@@ -108,7 +116,7 @@ defineExpose({
108116 '--mask-scroll-container-gradient-color': props.gradientColor,
109117 } : {}"
110118 >
111- <ScrollArea ref =" scrollAreaRef" :class =" cn('relative z-0 flex-1', props.contentClass)" :scrollbar =" props.scrollbar" :on-wheel =" onWheel" >
119+ <ScrollArea ref =" scrollAreaRef" :class =" cn('relative z-0 flex-1', props.contentClass)" :scrollbar =" props.scrollbar" :on-scroll = " onScroll " :on- wheel =" onWheel" >
112120 <slot />
113121 <ScrollBar v-if =" props.horizontal" orientation =" horizontal" :class =" { 'opacity-0 pointer-events-none': !props.scrollbar }" />
114122 </ScrollArea >
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import ScrollBar from './ScrollBar.vue'
1313const props = defineProps < ScrollAreaRootProps & {
1414 class?: HTMLAttributes [' class' ]
1515 scrollbar ?: boolean
16+ onScroll ?: (event : Event ) => void
1617 onWheel ?: (event : WheelEvent ) => void
1718}> ()
1819
@@ -31,7 +32,7 @@ defineExpose({
3132
3233<template >
3334 <ScrollAreaRoot v-bind =" delegatedProps" :class =" cn('relative overflow-hidden', props.class)" >
34- <ScrollAreaViewport ref =" viewportRef" class =" scroll-area-viewport h-full w-full rounded-[inherit]" @wheel.prevent =" onWheel" >
35+ <ScrollAreaViewport ref =" viewportRef" class =" scroll-area-viewport h-full w-full rounded-[inherit]" @scroll = " onScroll " @ wheel =" onWheel" >
3536 <slot />
3637 </ScrollAreaViewport >
3738 <ScrollBar :class =" { 'opacity-0 pointer-events-none': !props.scrollbar }" />
You can’t perform that action at this time.
0 commit comments