Browse Source

chore: add alias for getTooltipContainer

pull/4355/head
Benjy Cui 8 years ago
parent
commit
114016dd4e
  1. 4
      components/tooltip/index.en-US.md
  2. 5
      components/tooltip/index.tsx
  3. 4
      components/tooltip/index.zh-CN.md

4
components/tooltip/index.en-US.md

@ -24,10 +24,10 @@ The following APIs are shared by Tooltip, Popconfirm, Popover.
| Property | Description | Type | Default |
|-----------|------------------------------------------|------------|--------|
| placement | to set the position, which can be one of `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom` | string | top |
| getTooltipContainer | to set the container of the tip, while the default is to create a `div` element in `body` | Function(triggerNode) | () => document.body |
| getPopupContainer | to set the container of the tip, while the default is to create a `div` element in `body`. Use `getTooltipContainer` if you are using `antd@<2.5.2` | Function(triggerNode) | () => document.body |
| arrowPointAtCenter | whether arrow pointed at the center of target, supported after `antd@1.11+` | Boolean | `false` |
| visible | make the float card visible or not | boolean | false |
| onVisibleChange | callback of the visible attribute changed | function(visible) | none |
| onVisibleChange | callback of the visible attribute changed | (visible) => void | none |
| trigger | triggering mode: can be hover, focus, or click. | string | hover |
| overlayClassName | class name of the card | string | none |
| overlayStyle | style of the card | object | none |

5
components/tooltip/index.tsx

@ -22,7 +22,9 @@ export interface AbstractTooltipProps {
trigger?: 'hover' | 'focus' | 'click';
openClassName?: string;
arrowPointAtCenter?: boolean;
// getTooltipContainer had been rename to getPopupDomNode
getTooltipContainer?: (triggerNode: Element) => HTMLElement;
getPopupContainer?: (triggerNode: Element) => HTMLElement;
children?: React.ReactElement<any>;
}
@ -117,7 +119,7 @@ export default class Tooltip extends React.Component<TooltipProps, any> {
render() {
const { props, state } = this;
const { prefixCls, title, overlay, openClassName } = props;
const { prefixCls, title, overlay, openClassName, getPopupContainer, getTooltipContainer } = props;
const children = props.children as React.ReactElement<any>;
let visible = state.visible;
// Hide tooltip when there is no title
@ -134,6 +136,7 @@ export default class Tooltip extends React.Component<TooltipProps, any> {
return (
<RcTooltip
{...this.props}
getTooltipContainer={getPopupContainer || getTooltipContainer}
ref="tooltip"
builtinPlacements={this.getPlacements()}
overlay={overlay || title}

4
components/tooltip/index.zh-CN.md

@ -26,10 +26,10 @@ title: Tooltip
| 参数 | 说明 | 类型 | 默认值 |
|-----------|------------------------------------------|------------|--------|
| placement | 气泡框位置,可选 `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom` | string | top |
| getTooltipContainer | 浮层渲染父节点。默认渲染到 body 上 | Function(triggerNode) | () => document.body |
| getPopupContainer | 浮层渲染父节点,默认渲染到 body 上。`2.5.2` 之前请使用 `getTooltipContainer` | Function(triggerNode) | () => document.body |
| arrowPointAtCenter | 箭头是否指向目标元素中心,`antd@1.11+` 支持 | Boolean | `false` |
| visible | 用于手动控制浮层显隐 | boolean | false |
| onVisibleChange | 显示隐藏的回调 | function(visible) | 无 |
| onVisibleChange | 显示隐藏的回调 | (visible) => void | 无 |
| trigger | 触发行为,可选 `hover/focus/click` | string | hover |
| overlayClassName | 卡片类名 | string | 无 |
| overlayStyle | 卡片样式 | object | 无 |

Loading…
Cancel
Save