From 28b14c9c0d5668e52500b1edefd1164d84a63814 Mon Sep 17 00:00:00 2001 From: Alberto Marchetti Date: Sun, 26 May 2019 08:11:13 +0300 Subject: [PATCH] Allow users to define where tooltips should appear on slider marks (#16641) --- components/slider/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/slider/index.tsx b/components/slider/index.tsx index 835b4046af..f39ad42030 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import RcSlider from 'rc-slider/lib/Slider'; import RcRange from 'rc-slider/lib/Range'; import RcHandle from 'rc-slider/lib/Handle'; -import Tooltip from '../tooltip'; +import Tooltip, { TooltipPlacement } from '../tooltip'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; export interface SliderMarks { @@ -48,6 +48,7 @@ export interface SliderProps { id?: string; style?: React.CSSProperties; tooltipVisible?: boolean; + tooltipPlacement?: TooltipPlacement; } export interface SliderState { @@ -82,7 +83,7 @@ export default class Slider extends React.Component { tooltipPrefixCls: string, { value, dragging, index, ...restProps }, ) => { - const { tipFormatter, tooltipVisible } = this.props; + const { tipFormatter, tooltipVisible, tooltipPlacement } = this.props; const { visibles } = this.state; const isTipFormatter = tipFormatter ? visibles[index] || dragging : false; const visible = tooltipVisible || (tooltipVisible === undefined && isTipFormatter); @@ -91,7 +92,7 @@ export default class Slider extends React.Component { prefixCls={tooltipPrefixCls} title={tipFormatter ? tipFormatter(value) : ''} visible={visible} - placement="top" + placement={tooltipPlacement || 'top'} transitionName="zoom-down" key={index} >