Skip to content

ScrollRect

Main component of the scroll area.

Props

NameDescTypeDefault value
scroll
Scroll direction
'both'│'none'│'vertical'│'horizontal''both'
scrollBarAlwaysShowShow scroll bar always, otherwise show scroll bar when mouse overbooleanfalse
scrollBarBackgroundClickableIs able to click scroll bar background to set scroll position? (When scrollBarAlwaysShow is true)booleanfalse
containerClassCSS class of inner containerstring-

Events

NameDescParams
scrollThis event is triggered when the container scrolls.scrollLeft, scrollTop
resizedThis event is triggered when the container content size changes.scrollWidth, scrollHeight

Slots

NameDescParams
scrollBarXHorizontal scroll barScrollRectScrollBarSlotParams
scrollBarYVertical scroll barScrollRectScrollBarSlotParams

ScrollRectScrollBarSlotParams

js
{ scrollValue, onScroll }

Interface scrollBarValue:

NameTypeDesc
showbooleanIs scrollbar visible?
sizenumberScroll bar calculation length (percentage, 0-100)
sizeRawnumberScroll bar calculation length (pixel)
posnumberScroll bar scrolling position (percentage, 0-100)

Function onScroll:

ParamNameType
posnumberScroll bar scrolling position callback (percentage, 0-100)

ScrollRectInstance

Component interface, representing an instance of the component export method.

You can use (this.$refs.myScrollBar as ScrollRectInstance) or const myScrollBar = ref<ScrollRectInstance>() to reference component instance.

scrollTo(x: number, y: number): void

Scroll to position.

NameDesc
xX scroll pos (pixel)
yY scroll pos (pixel)

scrollToTop(): void

Scroll to top.

scrollToBottom(): void

Scroll to bottom.

getScrollContainer(): HTMLElement | undefined

To obtain the internal scrolling container element, you can retrieve its scrollTop and scrollLeft to obtain scrolling values or control scrolling.

Returns

Desc
Container

refreshScrollState(): void

Force refresh of scrollbar status. If the scrollbar status is not updated, you can call this method to force a refresh.

Released under the MIT License.