Skip to content

Commit

Permalink
feat(sticky-scroll): add offset prop
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed Aug 25, 2024
1 parent b7983ed commit ab414f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineComponent } from 'vue'
import { defineStory } from '../../../.storybook/types'
import VaStickyScrollbar from './StickyScrollbar.vue'
import VaStickyScrollbar from './VaStickyScrollbar.vue'

export default {
title: 'VaStickyScrollbar',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { getScrollbarSize } from '../../utils/scrollbar-size'
import { useEvent, useElementRect, useResizeObserver } from '../../composables'
import { useEvent, useElementRect, useResizeObserver, useNumericProp } from '../../composables'
const props = withDefaults(defineProps<{
el?: HTMLElement | null
direction?: 'vertical' | 'horizontal'
direction?: 'vertical' | 'horizontal',
offset?: number | string,
}>(), {
direction: 'horizontal',
offset: 0,
})
const currentEl = ref(null as HTMLElement | null)
const offsetProp = useNumericProp('offset')
const parentElement = computed(() => {
if (props.el) { return props.el }
Expand Down Expand Up @@ -49,7 +53,7 @@ const stickyScrollWrapperStyle = computed(() => {
return {
position: 'fixed' as const,
top: `${Math.min(bottom, window.innerHeight) - scrollSize}px`,
top: `${Math.min(bottom, window.innerHeight) - scrollSize - Number(offsetProp.value)}px`,
width: `${parentEl.clientWidth}px`,
overflowX: 'auto' as const,
overflowY: 'hidden' as const,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/va-sticky-scrollbar/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as VaStickyScrollbar } from './StickyScrollbar.vue'
export { default as VaStickyScrollbar } from './VaStickyScrollbar.vue'

0 comments on commit ab414f9

Please sign in to comment.