From 5d6e9298d27ef8092425bb90997d05709a545fc4 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Thu, 26 Dec 2024 14:42:21 +0800 Subject: [PATCH] docs(components): [anchor] add `selectScrollTop` prop (#19293) * docs(components): [anchor] add `scrollTop` prop * feat: rename --- docs/en-US/component/anchor.md | 19 ++++++++++--------- packages/components/anchor/src/anchor.ts | 2 +- packages/components/anchor/src/anchor.vue | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/en-US/component/anchor.md b/docs/en-US/component/anchor.md index e4738d5a29..c6173b8c8a 100644 --- a/docs/en-US/component/anchor.md +++ b/docs/en-US/component/anchor.md @@ -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 diff --git a/packages/components/anchor/src/anchor.ts b/packages/components/anchor/src/anchor.ts index db4c0acdec..15db694928 100644 --- a/packages/components/anchor/src/anchor.ts +++ b/packages/components/anchor/src/anchor.ts @@ -63,7 +63,7 @@ export const anchorProps = buildProps({ /** * @description Scroll whether link is selected at the top */ - scrollTop: { + selectScrollTop: { type: Boolean, default: false, }, diff --git a/packages/components/anchor/src/anchor.vue b/packages/components/anchor/src/anchor.vue index e1105fd2f8..9d7208a889 100644 --- a/packages/components/anchor/src/anchor.vue +++ b/packages/components/anchor/src/anchor.vue @@ -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