mirror of
https://github.com/wassname/slider.git
synced 2026-09-11 12:42:49 +08:00
react-component/slider#32 implemented tipFormatter prop
This commit is contained in:
+3
-2
@@ -24,7 +24,7 @@ export default class Handle extends React.Component {
|
||||
|
||||
render() {
|
||||
const props = this.props;
|
||||
const {className, tipTransitionName, offset, value} = props;
|
||||
const {className, tipTransitionName, tipFormatter, offset, value} = props;
|
||||
const {dragging, noTip} = props;
|
||||
|
||||
const style = { left: offset + '%' };
|
||||
@@ -42,7 +42,7 @@ export default class Handle extends React.Component {
|
||||
prefixCls={className.replace('handle', 'tooltip')}
|
||||
placement={{points: ['bc', 'tc']}}
|
||||
visible={isTooltipVisible}
|
||||
overlay={<span>{value}</span>}
|
||||
overlay={<span>{tipFormatter ? tipFormatter(value) : value}</span>}
|
||||
delay={0}
|
||||
transitionName={tipTransitionName}>
|
||||
{handle}
|
||||
@@ -54,6 +54,7 @@ Handle.propTypes = {
|
||||
className: React.PropTypes.string,
|
||||
offset: React.PropTypes.number,
|
||||
tipTransitionName: React.PropTypes.string,
|
||||
tipFormatter: React.PropTypes.func,
|
||||
value: React.PropTypes.number,
|
||||
dragging: React.PropTypes.bool,
|
||||
noTip: React.PropTypes.bool,
|
||||
|
||||
+5
-4
@@ -331,7 +331,7 @@ class Slider extends React.Component {
|
||||
const {handle, upperBound, lowerBound} = this.state;
|
||||
const props = this.props;
|
||||
const {className, prefixCls, disabled, included, isIncluded, dots, withDots, range} = props;
|
||||
const {marks, step, max, min, tipTransitionName, children} = props;
|
||||
const {marks, step, max, min, tipTransitionName, tipFormatter, children} = props;
|
||||
const marksLen = marks.length;
|
||||
|
||||
const sliderClassName = rcUtil.classSet({
|
||||
@@ -350,13 +350,13 @@ class Slider extends React.Component {
|
||||
}
|
||||
|
||||
const handleClassName = prefixCls + '-handle';
|
||||
const isNoTip = marksLen > 0;
|
||||
const upper = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip}
|
||||
const isNoTip = (marksLen > 0) && !tipFormatter;
|
||||
const upper = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip} tipFormatter={tipFormatter}
|
||||
offset={upperOffset} value={upperBound} dragging={handle === 'upperBound'} />);
|
||||
|
||||
let lower = null;
|
||||
if (range) {
|
||||
lower = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip}
|
||||
lower = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip} tipFormatter={tipFormatter}
|
||||
offset={lowerOffset} value={lowerBound} dragging={handle === 'lowerBound'} />);
|
||||
}
|
||||
|
||||
@@ -418,6 +418,7 @@ Slider.propTypes = {
|
||||
onChange: React.PropTypes.func,
|
||||
onAfterChange: React.PropTypes.func,
|
||||
tipTransitionName: React.PropTypes.string,
|
||||
tipFormatter: React.PropTypes.func,
|
||||
withDots: React.PropTypes.bool, // @Deprecated
|
||||
dots: React.PropTypes.bool,
|
||||
range: React.PropTypes.bool,
|
||||
|
||||
Reference in New Issue
Block a user