Skip to content

Commit

Permalink
feat: anchor add wrapperClass and wrapperStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jan 23, 2019
1 parent e0a9209 commit 1aa42df
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/anchor/Anchor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import addEventListener from '../_util/Dom/addEventListener';
import Affix from '../affix';
import getScroll from '../_util/getScroll';
import raf from 'raf';
import { initDefaultProps, getClass } from '../_util/props-util';
import { initDefaultProps } from '../_util/props-util';
import BaseMixin from '../_util/BaseMixin';

function getDefaultContainer() {
Expand Down Expand Up @@ -82,6 +82,8 @@ export const AnchorProps = {
affix: PropTypes.bool,
showInkInFixed: PropTypes.bool,
getContainer: PropTypes.func,
wrapperClass: PropTypes.string,
wrapperStyle: PropTypes.object,
};

export default {
Expand Down Expand Up @@ -213,15 +215,15 @@ export default {
visible: activeLink,
});

const wrapperClass = classNames(getClass(this), `${prefixCls}-wrapper`);
const wrapperClass = classNames(this.wrapperClass, `${prefixCls}-wrapper`);

const anchorClass = classNames(prefixCls, {
fixed: !affix && !showInkInFixed,
});

const wrapperStyle = {
maxHeight: offsetTop ? `calc(100vh - ${offsetTop}px)` : '100vh',
// ...getStyle(this, true),
...this.wrapperStyle,
};

const anchorContent = (
Expand Down
2 changes: 2 additions & 0 deletions components/anchor/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
| offsetBottom | Pixels to offset from bottom when calculating position of scroll | number | - |
| offsetTop | Pixels to offset from top when calculating position of scroll | number | 0 |
| showInkInFixed | Whether show ink-balls in Fixed mode | boolean | false |
| wrapperClass | The class name of the container | string | - |
| wrapperStyle | The style of the container | object | - |

### Events
| Events Name | Description | Arguments |
Expand Down
2 changes: 2 additions & 0 deletions components/anchor/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
| offsetBottom | 距离窗口底部达到指定偏移量后触发 | number | |
| offsetTop | 距离窗口顶部达到指定偏移量后触发 | number | |
| showInkInFixed | 固定模式是否显示小圆点 | boolean | false |
| wrapperClass | 容器的类名 | string | - |
| wrapperStyle | 容器样式 | object | - |

### 事件
| 事件名称 | 说明 | 回调参数 |
Expand Down
12 changes: 12 additions & 0 deletions types/anchor/anchor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,16 @@ export declare class Anchor extends AntdComponent {
* @type boolean
*/
showInkInFixed: boolean;

/**
* The class name of the container
* @type string
*/
wrapperClass: string;

/**
* The style of the container
* @type object
*/
wrapperStyle: object;
}

0 comments on commit 1aa42df

Please sign in to comment.