mirror of
https://github.com/wassname/slider.git
synced 2026-09-10 12:38:09 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab494c9ca8 | ||
|
|
68bb3bcadb | ||
|
|
0f97361257 | ||
|
|
599771dc1a | ||
|
|
a109298acd | ||
|
|
3519ba24c0 |
@@ -148,6 +148,12 @@ ReactDOM.render(<Rcslider />, container);
|
||||
<td>''</td>
|
||||
<td>Set the animation for tooltip if it shows.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tipFormatter</td>
|
||||
<td>func</td>
|
||||
<td></td>
|
||||
<td>Format the value of the tooltip if it shows.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>dots</td>
|
||||
<td>bool</td>
|
||||
|
||||
+2
-2
@@ -151,8 +151,8 @@
|
||||
}
|
||||
|
||||
&-inner {
|
||||
padding: 6px 0;
|
||||
width: 24px;
|
||||
padding: 6px 2px;
|
||||
min-width: 24px;
|
||||
height: 24px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
|
||||
@@ -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={log} tipFormatter={percentFormatter} tipTransitionName='rc-slider-tooltip-zoom-down' />
|
||||
</div>
|
||||
</div>
|
||||
, document.getElementById('__react-content'));
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-slider",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"description": "slider ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
||||
+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