mirror of
https://github.com/wassname/slider.git
synced 2026-09-09 11:35:22 +08:00
Merge branch 'thorbenziemek-master'
This commit is contained in:
@@ -9,6 +9,10 @@ var style = {width:400,margin:50};
|
||||
|
||||
var log = console.log.bind(console);
|
||||
|
||||
function percentFormatter(v) {
|
||||
return v + " %";
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<div>
|
||||
<div style={style}>
|
||||
@@ -39,5 +43,9 @@ ReactDOM.render(
|
||||
<p>分段式滑块(并列关系)</p>
|
||||
<Slider marks={["状态1","状态2","状态3","状态4"]} included={false} defaultIndex={1} />
|
||||
</div>
|
||||
<div style={style}>
|
||||
<p>基础滑块</p>
|
||||
<Slider onChange={onChange} tipFormatter={percentFormatter} tipTransitionName='rc-slider-tooltip-zoom-down' />
|
||||
</div>
|
||||
</div>
|
||||
, document.getElementById('__react-content'));
|
||||
|
||||
+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="top"
|
||||
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,
|
||||
|
||||
+7
-6
@@ -309,7 +309,7 @@ class Slider extends React.Component {
|
||||
const {handle, upperBound, lowerBound} = this.state;
|
||||
const props = this.props;
|
||||
const {className, prefixCls, disabled, included, isIncluded, dots, 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 = classSet({
|
||||
@@ -328,14 +328,14 @@ class Slider extends React.Component {
|
||||
}
|
||||
|
||||
const handleClassName = prefixCls + '-handle';
|
||||
const isNoTip = marksLen > 0;
|
||||
const upper = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip}
|
||||
offset={upperOffset} value={upperBound} dragging={handle === 'upperBound'}/>);
|
||||
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}
|
||||
offset={lowerOffset} value={lowerBound} dragging={handle === 'lowerBound'}/>);
|
||||
lower = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip} tipFormatter={tipFormatter}
|
||||
offset={lowerOffset} value={lowerBound} dragging={handle === 'lowerBound'} />);
|
||||
}
|
||||
|
||||
const upperIndex = this.getIndex(upperBound);
|
||||
@@ -396,6 +396,7 @@ Slider.propTypes = {
|
||||
onChange: React.PropTypes.func,
|
||||
onAfterChange: React.PropTypes.func,
|
||||
tipTransitionName: React.PropTypes.string,
|
||||
tipFormatter: React.PropTypes.func,
|
||||
dots: React.PropTypes.bool,
|
||||
range: React.PropTypes.bool,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user