diff --git a/components/anchor/anchorHelper.tsx b/components/anchor/anchorHelper.tsx index f80240e41f..7d922c5d72 100644 --- a/components/anchor/anchorHelper.tsx +++ b/components/anchor/anchorHelper.tsx @@ -40,11 +40,12 @@ export function getOffsetTop(element): number { export function scrollTo(href, target = getDefaultTarget) { const scrollTop = getScroll(target(), true); const offsetTop = getOffsetTop(document.querySelector(href)); + const targetScrollTop = scrollTop + offsetTop; const startTime = Date.now(); const frameFunc = () => { const timestamp = Date.now(); const time = timestamp - startTime; - document.body.scrollTop = easeInOutCubic(time, scrollTop, offsetTop, 450); + document.body.scrollTop = easeInOutCubic(time, scrollTop, targetScrollTop, 450); if (time < 450) { reqAnimFrame(frameFunc); } diff --git a/components/anchor/demo/basic.md b/components/anchor/demo/basic.md index da74d079d8..fb1795dbc9 100644 --- a/components/anchor/demo/basic.md +++ b/components/anchor/demo/basic.md @@ -15,12 +15,12 @@ The simplest usage. ```jsx import { Anchor } from 'antd'; -const { AnchorLink } = Anchor; +const { Link } = Anchor; ReactDOM.render( - - + + , mountNode); ``` \ No newline at end of file diff --git a/components/anchor/demo/independ.md b/components/anchor/demo/independ.md index ca9a94c7a9..ae0000daf5 100644 --- a/components/anchor/demo/independ.md +++ b/components/anchor/demo/independ.md @@ -15,9 +15,9 @@ Independent AnchorLink ```jsx import { Anchor } from 'antd'; -const { AnchorLink } = Anchor; +const { Link } = Anchor; ReactDOM.render( - + , mountNode); ``` \ No newline at end of file diff --git a/components/anchor/demo/mix.md b/components/anchor/demo/mix.md index d640fcd10e..89cfd014f4 100644 --- a/components/anchor/demo/mix.md +++ b/components/anchor/demo/mix.md @@ -15,14 +15,14 @@ The simplest usage. ```jsx import { Anchor } from 'antd'; -const { AnchorLink } = Anchor; +const { Link } = Anchor; ReactDOM.render( - - - - + + + + , mountNode); ``` \ No newline at end of file diff --git a/components/anchor/index.en-US.md b/components/anchor/index.en-US.md index d36c48aade..e5ef176a41 100644 --- a/components/anchor/index.en-US.md +++ b/components/anchor/index.en-US.md @@ -21,7 +21,7 @@ For displaying anchor hyperlink on page, and jump between then. | offsetBottom | Pixels to offset from bottom when calculating position of scroll | Number | - | | bounds | Bounding distance of anchor area | Number | 5(px) | -### AnchorLink Props +### Link Props | Property | Description | Type | Default | |-------------|----------------|--------------------|--------------| diff --git a/components/anchor/index.tsx b/components/anchor/index.tsx index cb60ca11e3..9149590015 100644 --- a/components/anchor/index.tsx +++ b/components/anchor/index.tsx @@ -14,7 +14,7 @@ export interface AnchorProps { } export default class Anchor extends React.Component { - static AnchorLink = AnchorLink; + static Link = AnchorLink; static defaultProps = { prefixCls: 'ant-anchor', diff --git a/components/anchor/index.zh-CN.md b/components/anchor/index.zh-CN.md index 93d47aba9d..5d8d221390 100644 --- a/components/anchor/index.zh-CN.md +++ b/components/anchor/index.zh-CN.md @@ -21,7 +21,8 @@ title: Anchor | offsetTop | 距离窗口顶部达到指定偏移量后触发 | Number | | | offsetBottom | 距离窗口底部达到指定偏移量后触发 | Number | | | bounds | 锚点区域边界 | Number | 5(px) | -### AnchorLink Props + +### Link Props | 成员 | 说明 | 类型 | 默认值 | |-------------|----------------|--------------------|--------------|