Skip to content

Commit 1aa42df

Browse files
committed
feat: anchor add wrapperClass and wrapperStyle
1 parent e0a9209 commit 1aa42df

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Diff for: components/anchor/Anchor.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import addEventListener from '../_util/Dom/addEventListener';
44
import Affix from '../affix';
55
import getScroll from '../_util/getScroll';
66
import raf from 'raf';
7-
import { initDefaultProps, getClass } from '../_util/props-util';
7+
import { initDefaultProps } from '../_util/props-util';
88
import BaseMixin from '../_util/BaseMixin';
99

1010
function getDefaultContainer() {
@@ -82,6 +82,8 @@ export const AnchorProps = {
8282
affix: PropTypes.bool,
8383
showInkInFixed: PropTypes.bool,
8484
getContainer: PropTypes.func,
85+
wrapperClass: PropTypes.string,
86+
wrapperStyle: PropTypes.object,
8587
};
8688

8789
export default {
@@ -213,15 +215,15 @@ export default {
213215
visible: activeLink,
214216
});
215217

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

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

222224
const wrapperStyle = {
223225
maxHeight: offsetTop ? `calc(100vh - ${offsetTop}px)` : '100vh',
224-
// ...getStyle(this, true),
226+
...this.wrapperStyle,
225227
};
226228

227229
const anchorContent = (

Diff for: components/anchor/index.en-US.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
| offsetBottom | Pixels to offset from bottom when calculating position of scroll | number | - |
1212
| offsetTop | Pixels to offset from top when calculating position of scroll | number | 0 |
1313
| showInkInFixed | Whether show ink-balls in Fixed mode | boolean | false |
14+
| wrapperClass | The class name of the container | string | - |
15+
| wrapperStyle | The style of the container | object | - |
1416

1517
### Events
1618
| Events Name | Description | Arguments |

Diff for: components/anchor/index.zh-CN.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
| offsetBottom | 距离窗口底部达到指定偏移量后触发 | number | |
1212
| offsetTop | 距离窗口顶部达到指定偏移量后触发 | number | |
1313
| showInkInFixed | 固定模式是否显示小圆点 | boolean | false |
14+
| wrapperClass | 容器的类名 | string | - |
15+
| wrapperStyle | 容器样式 | object | - |
1416

1517
### 事件
1618
| 事件名称 | 说明 | 回调参数 |

Diff for: types/anchor/anchor.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,16 @@ export declare class Anchor extends AntdComponent {
4848
* @type boolean
4949
*/
5050
showInkInFixed: boolean;
51+
52+
/**
53+
* The class name of the container
54+
* @type string
55+
*/
56+
wrapperClass: string;
57+
58+
/**
59+
* The style of the container
60+
* @type object
61+
*/
62+
wrapperStyle: object;
5163
}

0 commit comments

Comments
 (0)