mirror of
https://github.com/wassname/slider.git
synced 2026-09-11 12:42:49 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab494c9ca8 | ||
|
|
68bb3bcadb | ||
|
|
0f97361257 | ||
|
|
599771dc1a | ||
|
|
a109298acd | ||
|
|
3519ba24c0 |
@@ -148,6 +148,12 @@ ReactDOM.render(<Rcslider />, container);
|
|||||||
<td>''</td>
|
<td>''</td>
|
||||||
<td>Set the animation for tooltip if it shows.</td>
|
<td>Set the animation for tooltip if it shows.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>tipFormatter</td>
|
||||||
|
<td>func</td>
|
||||||
|
<td></td>
|
||||||
|
<td>Format the value of the tooltip if it shows.</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>dots</td>
|
<td>dots</td>
|
||||||
<td>bool</td>
|
<td>bool</td>
|
||||||
|
|||||||
+2
-2
@@ -151,8 +151,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-inner {
|
&-inner {
|
||||||
padding: 6px 0;
|
padding: 6px 2px;
|
||||||
width: 24px;
|
min-width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ var style = {width:400,margin:50};
|
|||||||
|
|
||||||
var log = console.log.bind(console);
|
var log = console.log.bind(console);
|
||||||
|
|
||||||
|
function percentFormatter(v) {
|
||||||
|
return v + " %";
|
||||||
|
}
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<div>
|
<div>
|
||||||
<div style={style}>
|
<div style={style}>
|
||||||
@@ -39,5 +43,9 @@ ReactDOM.render(
|
|||||||
<p>分段式滑块(并列关系)</p>
|
<p>分段式滑块(并列关系)</p>
|
||||||
<Slider marks={["状态1","状态2","状态3","状态4"]} included={false} defaultIndex={1} />
|
<Slider marks={["状态1","状态2","状态3","状态4"]} included={false} defaultIndex={1} />
|
||||||
</div>
|
</div>
|
||||||
|
<div style={style}>
|
||||||
|
<p>基础滑块</p>
|
||||||
|
<Slider onChange={log} tipFormatter={percentFormatter} tipTransitionName='rc-slider-tooltip-zoom-down' />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
, document.getElementById('__react-content'));
|
, document.getElementById('__react-content'));
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rc-slider",
|
"name": "rc-slider",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"description": "slider ui component for react",
|
"description": "slider ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
|||||||
+3
-2
@@ -24,7 +24,7 @@ export default class Handle extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
const {className, tipTransitionName, offset, value} = props;
|
const {className, tipTransitionName, tipFormatter, offset, value} = props;
|
||||||
const {dragging, noTip} = props;
|
const {dragging, noTip} = props;
|
||||||
|
|
||||||
const style = { left: offset + '%' };
|
const style = { left: offset + '%' };
|
||||||
@@ -42,7 +42,7 @@ export default class Handle extends React.Component {
|
|||||||
prefixCls={className.replace('handle', 'tooltip')}
|
prefixCls={className.replace('handle', 'tooltip')}
|
||||||
placement="top"
|
placement="top"
|
||||||
visible={isTooltipVisible}
|
visible={isTooltipVisible}
|
||||||
overlay={<span>{value}</span>}
|
overlay={<span>{tipFormatter ? tipFormatter(value) : value}</span>}
|
||||||
delay={0}
|
delay={0}
|
||||||
transitionName={tipTransitionName}>
|
transitionName={tipTransitionName}>
|
||||||
{handle}
|
{handle}
|
||||||
@@ -54,6 +54,7 @@ Handle.propTypes = {
|
|||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
offset: React.PropTypes.number,
|
offset: React.PropTypes.number,
|
||||||
tipTransitionName: React.PropTypes.string,
|
tipTransitionName: React.PropTypes.string,
|
||||||
|
tipFormatter: React.PropTypes.func,
|
||||||
value: React.PropTypes.number,
|
value: React.PropTypes.number,
|
||||||
dragging: React.PropTypes.bool,
|
dragging: React.PropTypes.bool,
|
||||||
noTip: React.PropTypes.bool,
|
noTip: React.PropTypes.bool,
|
||||||
|
|||||||
+5
-4
@@ -309,7 +309,7 @@ class Slider extends React.Component {
|
|||||||
const {handle, upperBound, lowerBound} = this.state;
|
const {handle, upperBound, lowerBound} = this.state;
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
const {className, prefixCls, disabled, included, isIncluded, dots, range} = 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 marksLen = marks.length;
|
||||||
|
|
||||||
const sliderClassName = classSet({
|
const sliderClassName = classSet({
|
||||||
@@ -328,13 +328,13 @@ class Slider extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleClassName = prefixCls + '-handle';
|
const handleClassName = prefixCls + '-handle';
|
||||||
const isNoTip = marksLen > 0;
|
const isNoTip = (marksLen > 0) && !tipFormatter;
|
||||||
const upper = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip}
|
const upper = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip} tipFormatter={tipFormatter}
|
||||||
offset={upperOffset} value={upperBound} dragging={handle === 'upperBound'} />);
|
offset={upperOffset} value={upperBound} dragging={handle === 'upperBound'} />);
|
||||||
|
|
||||||
let lower = null;
|
let lower = null;
|
||||||
if (range) {
|
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'} />);
|
offset={lowerOffset} value={lowerBound} dragging={handle === 'lowerBound'} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,6 +396,7 @@ Slider.propTypes = {
|
|||||||
onChange: React.PropTypes.func,
|
onChange: React.PropTypes.func,
|
||||||
onAfterChange: React.PropTypes.func,
|
onAfterChange: React.PropTypes.func,
|
||||||
tipTransitionName: React.PropTypes.string,
|
tipTransitionName: React.PropTypes.string,
|
||||||
|
tipFormatter: React.PropTypes.func,
|
||||||
dots: React.PropTypes.bool,
|
dots: React.PropTypes.bool,
|
||||||
range: React.PropTypes.bool,
|
range: React.PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user