|
1 | 1 | <script setup lang="ts">
|
2 | 2 | import { computed, ref } from 'vue'
|
3 | 3 | import { getScrollbarSize } from '../../utils/scrollbar-size'
|
4 |
| -import { useEvent, useElementRect, useResizeObserver } from '../../composables' |
| 4 | +import { useEvent, useElementRect, useResizeObserver, useNumericProp } from '../../composables' |
5 | 5 |
|
6 | 6 | const props = withDefaults(defineProps<{
|
7 | 7 | el?: HTMLElement | null
|
8 |
| - direction?: 'vertical' | 'horizontal' |
| 8 | + direction?: 'vertical' | 'horizontal', |
| 9 | + offset?: number | string, |
9 | 10 | }>(), {
|
10 | 11 | direction: 'horizontal',
|
| 12 | + offset: 0, |
11 | 13 | })
|
12 | 14 | const currentEl = ref(null as HTMLElement | null)
|
13 | 15 |
|
| 16 | +const offsetProp = useNumericProp('offset') |
| 17 | +
|
14 | 18 | const parentElement = computed(() => {
|
15 | 19 | if (props.el) { return props.el }
|
16 | 20 |
|
@@ -49,7 +53,7 @@ const stickyScrollWrapperStyle = computed(() => {
|
49 | 53 |
|
50 | 54 | return {
|
51 | 55 | position: 'fixed' as const,
|
52 |
| - top: `${Math.min(bottom, window.innerHeight) - scrollSize}px`, |
| 56 | + top: `${Math.min(bottom, window.innerHeight) - scrollSize - Number(offsetProp.value)}px`, |
53 | 57 | width: `${parentEl.clientWidth}px`,
|
54 | 58 | overflowX: 'auto' as const,
|
55 | 59 | overflowY: 'hidden' as const,
|
|
0 commit comments