diff --git a/docs/en-US/component/scrollbar.md b/docs/en-US/component/scrollbar.md index 4f72249cfd..1bd3ddda3d 100644 --- a/docs/en-US/component/scrollbar.md +++ b/docs/en-US/component/scrollbar.md @@ -39,39 +39,43 @@ scrollbar/manual-scroll ::: -## Scrollbar Attributes +## API -| Name | Description | Type | Accepted Values | Default | -| ---------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------- | --------------- | ------- | -| height | height of scrollbar | string / number | — | — | -| max-height | max height of scrollbar | string / number | — | — | -| native | whether to use the native scrollbar style | boolean | — | false | -| wrap-style | style of warp container | string | — | — | -| wrap-class | class of warp container | string | — | — | -| view-style | style of view | string | — | — | -| view-class | class of view | string | — | — | -| noresize | do not respond to container size changes, if the container size does not change, it is better to set it to optimize performance | boolean | — | false | -| tag | element tag of the view | string | — | div | -| always | always show scrollbar | boolean | — | false | -| min-size | minimum size of scrollbar | number | — | 20 | +### Attributes -## Scrollbar Events +| Name | Description | Type | Default | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- | ------- | +| height | height of scrollbar | ^[string] \| ^[number] | — | +| max-height | max height of scrollbar | ^[string] \| ^[number] | — | +| native | whether to use the native scrollbar style | ^[boolean] | false | +| wrap-style | style of wrap container | ^[string] \| ^[object]`CSSProperties \| CSSProperties[] \| string[]` | — | +| wrap-class | class of wrap container | ^[string] | — | +| view-style | style of view | ^[string] \| ^[object]`CSSProperties \| CSSProperties[] \| string[]` | — | +| view-class | class of view | ^[string] | — | +| noresize | do not respond to container size changes, if the container size does not change, it is better to set it to optimize performance | ^[boolean] | false | +| tag | element tag of the view | ^[string] | div | +| always | always show scrollbar | ^[boolean] | false | +| min-size | minimum size of scrollbar | ^[number] | 20 | -| Name | Description | Parameters | -| ------ | ----------------------- | ------------------------------------------------- | -| scroll | triggers when scrolling | distance of scrolling `{ scrollLeft, scrollTop }` | +### Events -## Scrollbar Methods +| Name | Description | Type | +| ------ | ----------------------------------------------------- | ---------------------------------------------------------------- | +| scroll | triggers when scrolling, return distance of scrolling | ^[Function]`({ scrollLeft: number, scrollTop: number }) => void` | -| Method | Description | Parameters | -| ------------- | ------------------------------------------ | ----------------------------------------------------- | -| scrollTo | scrolls to a particular set of coordinates | (options: ScrollToOptions \| number, yCoord?: number) | -| setScrollTop | Set distance to scroll top | (scrollTop: number) | -| setScrollLeft | Set distance to scroll left | (scrollLeft: number) | -| update | update scrollbar state manually | — | +### Slots -## Scrollbar Slots +| Name | Description | +| ------- | ------------------------- | +| default | customize default content | -| Name | Description | -| ---- | ------------------------- | -| — | customize default content | +### Exposes + +| Method | Description | Type | +| ------------- | ------------------------------------------ | -------------------------------------------------------------------------- | +| handleScroll | handle scroll event | ^[Function]`() => void` | +| scrollTo | scrolls to a particular set of coordinates | ^[Function]`(options: ScrollToOptions \| number, yCoord?: number) => void` | +| setScrollTop | Set distance to scroll top | ^[Function]`(scrollTop: number) => void` | +| setScrollLeft | Set distance to scroll left | ^[Function]`(scrollLeft: number) => void` | +| update | update scrollbar state manually | ^[Function]`() => void` | +| wrapRef | scrollbar wrap ref | ^[Object]`Ref` | diff --git a/packages/components/scrollbar/src/scrollbar.ts b/packages/components/scrollbar/src/scrollbar.ts index fec90cd4d3..b70f6f1791 100644 --- a/packages/components/scrollbar/src/scrollbar.ts +++ b/packages/components/scrollbar/src/scrollbar.ts @@ -3,37 +3,73 @@ import type { ExtractPropTypes, StyleValue } from 'vue' import type Scrollbar from './scrollbar.vue' export const scrollbarProps = buildProps({ + /** + * @description height of scrollbar + */ height: { type: [String, Number], default: '', }, + /** + * @description max height of scrollbar + */ maxHeight: { type: [String, Number], default: '', }, - native: Boolean, + /** + * @description whether to use the native scrollbar + */ + native: { + type: Boolean, + default: false, + }, + /** + * @description style of wrap + */ wrapStyle: { type: definePropType([String, Object, Array]), default: '', }, + /** + * @description class of wrap + */ wrapClass: { type: [String, Array], default: '', }, + /** + * @description class of view + */ viewClass: { type: [String, Array], default: '', }, + /** + * @description style of view + */ viewStyle: { type: [String, Array, Object], default: '', }, + /** + * @description do not respond to container size changes, if the container size does not change, it is better to set it to optimize performance + */ noresize: Boolean, // 如果 container 尺寸不会发生变化,最好设置它可以优化性能 + /** + * @description element tag of the view + */ tag: { type: String, default: 'div', }, + /** + * @description always show + */ always: Boolean, + /** + * @description minimum size of scrollbar + */ minSize: { type: Number, default: 20, diff --git a/packages/components/scrollbar/src/scrollbar.vue b/packages/components/scrollbar/src/scrollbar.vue index 88a3cabda0..3a547247fd 100644 --- a/packages/components/scrollbar/src/scrollbar.vue +++ b/packages/components/scrollbar/src/scrollbar.vue @@ -1,19 +1,10 @@