Compare commits

...
7 Commits
Author SHA1 Message Date
Benjy Cui ebf27cc9ba Merge pull request #24 from react-component/step-marks-fix
Step marks fix
2015-10-15 11:26:49 +08:00
SimaQ 314fc59d15 updata version. 2015-10-15 11:01:21 +08:00
SimaQ 7bd951072f fix: fix disabled style. 2015-10-15 11:01:21 +08:00
SimaQ d6779510f9 test: update test case. 2015-10-15 11:01:15 +08:00
SimaQ 2588a2b919 fix: fix#23. 2015-10-15 10:44:58 +08:00
yiminghe dd0a63dee3 change anim name 2015-10-14 23:08:51 +08:00
yiminghe 8b414d510b update travis 2015-10-14 23:06:24 +08:00
7 changed files with 54 additions and 34 deletions
+1 -2
View File
@@ -7,7 +7,7 @@ notifications:
- yiminghe@gmail.com
node_js:
- 0.12
- 4.0.0
before_install:
- |
@@ -16,7 +16,6 @@ before_install:
echo "Only docs were updated, stopping build process."
exit
fi
npm install mocha-phantomjs -g
phantomjs --version
script:
+6
View File
@@ -142,6 +142,12 @@ React.render(<Rcslider />, container);
<td>''</td>
<td>Set the animation for tooltip if it shows.</td>
</tr>
<tr>
<td>withDots</td>
<td>bool</td>
<td>false</td>
<td>For linear slider, when the `step` value is greater than 1, you can set the `withDots` to `true` if you want to render the slider bar with dots.</td>
</tr>
</tbody>
</table>
+6 -6
View File
@@ -121,13 +121,13 @@
background-color: @disabledColor;
}
.@{prefixClass}-handle {
.@{prefixClass}-handle, .@{prefixClass}-dot {
border-color: @disabledColor;
background-color: #fff;
cursor: not-allowed;
}
.@{prefixClass}-mark-text, .dot {
.@{prefixClass}-mark-text, .@{prefixClass}-dot {
cursor: not-allowed!important;
}
}
@@ -216,9 +216,9 @@
animation-timing-function: @ease-in-quint;
}
}
.zoom-motion(rc-slider-tooltip-zoom-down, rcSliderTooltipZoomDownOut);
.zoom-motion(rc-slider-tooltip-zoom-down, rcSliderTooltipZoomDown);
@keyframes rcSliderTooltipZoomDownOutIn {
@keyframes rcSliderTooltipZoomDownIn {
0% {
opacity: 0;
transform-origin: 50% 100%;
@@ -230,7 +230,7 @@
}
}
@keyframes rcSliderTooltipZoomDownOutOut {
@keyframes rcSliderTooltipZoomDownOut {
0% {
transform-origin: 50% 100%;
transform: scale(1, 1);
@@ -240,4 +240,4 @@
transform-origin: 50% 100%;
transform: scale(0, 0);
}
}
}
+1
View File
@@ -10,5 +10,6 @@ function onChange(v){
}
// React.render(<div style={{width:400,margin:100}}><Slider marks={["一","二","三","四","五"]} defaultIndex={2} /></div>, document.getElementById('__react-content'));
// React.render(<div style={{width:400,margin:100}}><Slider withDots className='rc-slider' step={20}/></div>, document.getElementById('__react-content'));
// React.render(<div style={{width:400,margin:100}}><Slider className='rc-slider' step={20}/></div>, document.getElementById('__react-content'));
React.render(<div style={{width:400,margin:100}}><Slider onChange={onChange} tipTransitionName='rc-slider-tooltip-zoom-down'/></div>, document.getElementById('__react-content'));
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-slider",
"version": "1.5.0",
"version": "1.5.1",
"description": "slider ui component for react",
"keywords": [
"react",
+31 -23
View File
@@ -57,6 +57,7 @@ const Slider = React.createClass({
onChange: React.PropTypes.func,
onAfterChange: React.PropTypes.func,
tipTransitionName: React.PropTypes.string,
withDots: React.PropTypes.bool,
},
getDefaultProps() {
@@ -72,6 +73,7 @@ const Slider = React.createClass({
disabled: false,
defaultIndex: 0,
tipTransitionName: '',
withDots: false,
};
},
@@ -208,37 +210,43 @@ const Slider = React.createClass({
renderSteps() {
const props = this.props;
const marksLen = props.marks.length;
const stepNum = marksLen > 0 ? marksLen : Math.floor((props.max - props.min) / props.step) + 1;
const unit = 100 / (stepNum - 1);
const withDots = props.withDots;
const prefixCls = props.prefixCls;
const stepClassName = prefixClsFn(prefixCls, 'step');
if (marksLen || withDots) {
const stepNum = marksLen ? marksLen : Math.floor((props.max - props.min) / props.step) + 1;
const unit = 100 / (stepNum - 1);
const elements = [];
for (let i = 0; i < stepNum; i++) {
const offset = unit * i + '%';
const style = {
left: offset,
};
let className = prefixClsFn(prefixCls, 'dot');
if (props.isIncluded) {
if (i <= this.getIndex()) {
className = prefixClsFn(prefixCls, 'dot', 'dot-active');
const prefixCls = props.prefixCls;
const stepClassName = prefixClsFn(prefixCls, 'step');
const elements = [];
for (let i = 0; i < stepNum; i++) {
const offset = unit * i + '%';
const style = {
left: offset,
};
let className = prefixClsFn(prefixCls, 'dot');
if (props.isIncluded) {
if (i <= this.getIndex()) {
className = prefixClsFn(prefixCls, 'dot', 'dot-active');
}
} else {
className = (i === this.getIndex()) ? prefixClsFn(prefixCls, 'dot', 'dot-active') : className;
}
} else {
className = (i === this.getIndex()) ? prefixClsFn(prefixCls, 'dot', 'dot-active') : className;
elements[i] = (
<span className={className} style={style} ref={'step' + i} key={'step' + i}></span>
);
}
elements[i] = (
<span className={className} style={style} ref={'step' + i} key={'step' + i}></span>
return (
<div className={stepClassName}>
{elements}
</div>
);
}
return (
<div className={stepClassName}>
{elements}
</div>
);
return null;
},
renderMark(i) {
+8 -2
View File
@@ -39,8 +39,14 @@ describe('rc-slider', function () {
expect(node.find('.rc-slider').length).to.be(1);
expect(node.find('.rc-slider-handle').length).to.be(1);
expect(node.find('.rc-slider-track').length).to.be(1);
expect(node.find('.rc-slider-dot').length).to.be(6);
expect(slider.state.value).to.be(0);
var sliderWithDots = React.render(
<Slider className='rc-slider' step={20} withDots/>,
div
);
var node1 = $(div);
expect(node1.find('.rc-slider-dot').length).to.be(6);
});
it('should render a slider with marks correctly!', function () {
@@ -64,7 +70,7 @@ describe('rc-slider', function () {
// div
// );
// var selectedStep = slider.refs.step3.getDOMNode();
// Simulate.mouseDown(selectedStep);
// setTimeout( function() {