Browse Source

feat(Anchor): fix getCurrentAnchor offset

pull/17827/head
shaodahong 5 years ago
committed by shao
parent
commit
32621cf41a
  1. 7
      components/anchor/Anchor.tsx

7
components/anchor/Anchor.tsx

@ -240,8 +240,11 @@ export default class Anchor extends React.Component<AnchorProps, AnchorState> {
return;
}
const { activeLink } = this.state;
const { offsetTop, bounds } = this.props;
const currentActiveLink = this.getCurrentAnchor(offsetTop, bounds);
const { offsetTop, bounds, targetOffset } = this.props;
const currentActiveLink = this.getCurrentAnchor(
targetOffset !== undefined ? targetOffset : offsetTop || 0,
bounds,
);
if (activeLink !== currentActiveLink) {
this.setState({
activeLink: currentActiveLink,

Loading…
Cancel
Save