Browse Source

Fix the problem that the Slider's Tooltip is in the incorrect position when use modal (#16717)

* Fix incorrect position of tooltip when use slider

* Remove useless comment

* Reduce code

* Update

*  getTooltipPopupContainer default to body

* Public Slider's ref

* Add docs

* Update docs
pull/16801/head
ztplz 6 years ago
committed by zombieJ
parent
commit
9793e30969
  1. 1
      components/slider/index.en-US.md
  2. 8
      components/slider/index.tsx
  3. 1
      components/slider/index.zh-CN.md

1
components/slider/index.en-US.md

@ -30,6 +30,7 @@ To input a value in a range.
| onAfterChange | Fire when `onmouseup` is fired. | Function(value) | NOOP |
| onChange | Callback function that is fired when the user changes the slider's value. | Function(value) | NOOP |
| tooltipVisible | If true, Tooltip will show always, or it will not show anyway, even if dragging or hovering. | Boolean | |
| getTooltipPopupContainer | The DOM container of the Tooltip, the default behavior is to create a div element in body. | Function | () => document.body |
## Methods

8
components/slider/index.tsx

@ -48,6 +48,7 @@ export interface SliderProps {
id?: string;
style?: React.CSSProperties;
tooltipVisible?: boolean;
getTooltipPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
}
export interface SliderState {
@ -61,7 +62,7 @@ export default class Slider extends React.Component<SliderProps, SliderState> {
},
};
private rcSlider: any;
rcSlider: typeof RcSlider;
constructor(props: SliderProps) {
super(props);
@ -82,7 +83,7 @@ export default class Slider extends React.Component<SliderProps, SliderState> {
tooltipPrefixCls: string,
{ value, dragging, index, ...restProps },
) => {
const { tipFormatter, tooltipVisible } = this.props;
const { tipFormatter, tooltipVisible, getTooltipPopupContainer } = this.props;
const { visibles } = this.state;
const isTipFormatter = tipFormatter ? visibles[index] || dragging : false;
const visible = tooltipVisible || (tooltipVisible === undefined && isTipFormatter);
@ -94,6 +95,9 @@ export default class Slider extends React.Component<SliderProps, SliderState> {
placement="top"
transitionName="zoom-down"
key={index}
getPopupContainer={
getTooltipPopupContainer ? getTooltipPopupContainer : () => document.body
}
>
<RcHandle
{...restProps}

1
components/slider/index.zh-CN.md

@ -31,6 +31,7 @@ title: Slider
| onAfterChange | 与 `onmouseup` 触发时机一致,把当前值作为参数传入。 | Function(value) | NOOP |
| onChange | 当 Slider 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入。 | Function(value) | NOOP |
| tooltipVisible | 值为`true`时,Tooltip 将会始终显示;否则始终不显示,哪怕在拖拽及移入时。 | Boolean | |
| getTooltipPopupContainer | Tooltip 渲染父节点,默认渲染到 body 上。 | Function | () => document.body |
## 方法

Loading…
Cancel
Save