docs(components): [anchor] add selectScrollTop prop (#19293)

* docs(components): [anchor] add `scrollTop` prop

* feat: rename
This commit is contained in:
btea
2024-12-26 14:42:21 +08:00
committed by GitHub
parent 0e9c6c062d
commit 5d6e9298d2
3 changed files with 12 additions and 11 deletions

View File

@@ -77,15 +77,16 @@ anchor/affix
### Anchor Attributes
| Property | Description | Type | Default |
| --------- | ---------------------------------------------------------- | -------------------------------------- | ---------- |
| container | scroll container. | `string` \| `HTMLElement` \| `Window ` | — |
| offset | set the offset of the anchor scroll. | `number` | 0 |
| bound | the offset of the element starting to trigger the anchor. | `number` | 15 |
| duration | set the scroll duration of the container, in milliseconds. | `number` | 300 |
| marker | whether to show the marker. | ^[boolean] | true |
| type | set Anchor type. | ^[enum]`'default' \| 'underline'` | `default` |
| direction | Set Anchor direction. | ^[enum]`'vertical' \| 'horizontal'` | `vertical` |
| Property | Description | Type | Default |
| -------------------------- | ---------------------------------------------------------- | -------------------------------------- | ---------- |
| container | scroll container. | `string` \| `HTMLElement` \| `Window ` | — |
| offset | set the offset of the anchor scroll. | `number` | 0 |
| bound | the offset of the element starting to trigger the anchor. | `number` | 15 |
| duration | set the scroll duration of the container, in milliseconds. | `number` | 300 |
| marker | whether to show the marker. | ^[boolean] | true |
| type | set Anchor type. | ^[enum]`'default' \| 'underline'` | `default` |
| direction | Set Anchor direction. | ^[enum]`'vertical' \| 'horizontal'` | `vertical` |
| select-scroll-top ^(2.9.2) | scroll whether link is selected at the top | ^[boolean] | false |
### Anchor Events

View File

@@ -63,7 +63,7 @@ export const anchorProps = buildProps({
/**
* @description Scroll whether link is selected at the top
*/
scrollTop: {
selectScrollTop: {
type: Boolean,
default: false,
},

View File

@@ -139,7 +139,7 @@ const getCurrentHref = () => {
const next = anchorTopList[i + 1]
if (i === 0 && scrollTop === 0) {
return props.scrollTop ? item.href : ''
return props.selectScrollTop ? item.href : ''
}
if (item.top <= scrollTop && (!next || next.top > scrollTop)) {
return item.href