Skip to content

Commit ab414f9

Browse files
committed
feat(sticky-scroll): add offset prop
1 parent b7983ed commit ab414f9

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

packages/ui/src/components/va-sticky-scrollbar/StickyScrollbar.stories.ts renamed to packages/ui/src/components/va-sticky-scrollbar/VaStickyScrollbar.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineComponent } from 'vue'
22
import { defineStory } from '../../../.storybook/types'
3-
import VaStickyScrollbar from './StickyScrollbar.vue'
3+
import VaStickyScrollbar from './VaStickyScrollbar.vue'
44

55
export default {
66
title: 'VaStickyScrollbar',

packages/ui/src/components/va-sticky-scrollbar/StickyScrollbar.vue renamed to packages/ui/src/components/va-sticky-scrollbar/VaStickyScrollbar.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<script setup lang="ts">
22
import { computed, ref } from 'vue'
33
import { getScrollbarSize } from '../../utils/scrollbar-size'
4-
import { useEvent, useElementRect, useResizeObserver } from '../../composables'
4+
import { useEvent, useElementRect, useResizeObserver, useNumericProp } from '../../composables'
55
66
const props = withDefaults(defineProps<{
77
el?: HTMLElement | null
8-
direction?: 'vertical' | 'horizontal'
8+
direction?: 'vertical' | 'horizontal',
9+
offset?: number | string,
910
}>(), {
1011
direction: 'horizontal',
12+
offset: 0,
1113
})
1214
const currentEl = ref(null as HTMLElement | null)
1315
16+
const offsetProp = useNumericProp('offset')
17+
1418
const parentElement = computed(() => {
1519
if (props.el) { return props.el }
1620
@@ -49,7 +53,7 @@ const stickyScrollWrapperStyle = computed(() => {
4953
5054
return {
5155
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`,
5357
width: `${parentEl.clientWidth}px`,
5458
overflowX: 'auto' as const,
5559
overflowY: 'hidden' as const,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default as VaStickyScrollbar } from './StickyScrollbar.vue'
1+
export { default as VaStickyScrollbar } from './VaStickyScrollbar.vue'

0 commit comments

Comments
 (0)