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 - yiminghe@gmail.com
node_js: node_js:
- 0.12 - 4.0.0
before_install: before_install:
- | - |
@@ -16,7 +16,6 @@ before_install:
echo "Only docs were updated, stopping build process." echo "Only docs were updated, stopping build process."
exit exit
fi fi
npm install mocha-phantomjs -g
phantomjs --version phantomjs --version
script: script:
+6
View File
@@ -142,6 +142,12 @@ React.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>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> </tbody>
</table> </table>
+6 -6
View File
@@ -121,13 +121,13 @@
background-color: @disabledColor; background-color: @disabledColor;
} }
.@{prefixClass}-handle { .@{prefixClass}-handle, .@{prefixClass}-dot {
border-color: @disabledColor; border-color: @disabledColor;
background-color: #fff; background-color: #fff;
cursor: not-allowed; cursor: not-allowed;
} }
.@{prefixClass}-mark-text, .dot { .@{prefixClass}-mark-text, .@{prefixClass}-dot {
cursor: not-allowed!important; cursor: not-allowed!important;
} }
} }
@@ -216,9 +216,9 @@
animation-timing-function: @ease-in-quint; 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% { 0% {
opacity: 0; opacity: 0;
transform-origin: 50% 100%; transform-origin: 50% 100%;
@@ -230,7 +230,7 @@
} }
} }
@keyframes rcSliderTooltipZoomDownOutOut { @keyframes rcSliderTooltipZoomDownOut {
0% { 0% {
transform-origin: 50% 100%; transform-origin: 50% 100%;
transform: scale(1, 1); transform: scale(1, 1);
@@ -240,4 +240,4 @@
transform-origin: 50% 100%; transform-origin: 50% 100%;
transform: scale(0, 0); 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 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 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')); 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", "name": "rc-slider",
"version": "1.5.0", "version": "1.5.1",
"description": "slider ui component for react", "description": "slider ui component for react",
"keywords": [ "keywords": [
"react", "react",
+31 -23
View File
@@ -57,6 +57,7 @@ const Slider = React.createClass({
onChange: React.PropTypes.func, onChange: React.PropTypes.func,
onAfterChange: React.PropTypes.func, onAfterChange: React.PropTypes.func,
tipTransitionName: React.PropTypes.string, tipTransitionName: React.PropTypes.string,
withDots: React.PropTypes.bool,
}, },
getDefaultProps() { getDefaultProps() {
@@ -72,6 +73,7 @@ const Slider = React.createClass({
disabled: false, disabled: false,
defaultIndex: 0, defaultIndex: 0,
tipTransitionName: '', tipTransitionName: '',
withDots: false,
}; };
}, },
@@ -208,37 +210,43 @@ const Slider = React.createClass({
renderSteps() { renderSteps() {
const props = this.props; const props = this.props;
const marksLen = props.marks.length; const marksLen = props.marks.length;
const stepNum = marksLen > 0 ? marksLen : Math.floor((props.max - props.min) / props.step) + 1; const withDots = props.withDots;
const unit = 100 / (stepNum - 1);
const prefixCls = props.prefixCls; if (marksLen || withDots) {
const stepClassName = prefixClsFn(prefixCls, 'step'); const stepNum = marksLen ? marksLen : Math.floor((props.max - props.min) / props.step) + 1;
const unit = 100 / (stepNum - 1);
const elements = []; const prefixCls = props.prefixCls;
for (let i = 0; i < stepNum; i++) { const stepClassName = prefixClsFn(prefixCls, 'step');
const offset = unit * i + '%';
const style = { const elements = [];
left: offset, for (let i = 0; i < stepNum; i++) {
}; const offset = unit * i + '%';
let className = prefixClsFn(prefixCls, 'dot'); const style = {
if (props.isIncluded) { left: offset,
if (i <= this.getIndex()) { };
className = prefixClsFn(prefixCls, 'dot', 'dot-active'); 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] = ( return (
<span className={className} style={style} ref={'step' + i} key={'step' + i}></span> <div className={stepClassName}>
{elements}
</div>
); );
} }
return ( return null;
<div className={stepClassName}>
{elements}
</div>
);
}, },
renderMark(i) { 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').length).to.be(1);
expect(node.find('.rc-slider-handle').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-track').length).to.be(1);
expect(node.find('.rc-slider-dot').length).to.be(6);
expect(slider.state.value).to.be(0); 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 () { it('should render a slider with marks correctly!', function () {
@@ -64,7 +70,7 @@ describe('rc-slider', function () {
// div // div
// ); // );
// var selectedStep = slider.refs.step3.getDOMNode(); // var selectedStep = slider.refs.step3.getDOMNode();
// Simulate.mouseDown(selectedStep); // Simulate.mouseDown(selectedStep);
// setTimeout( function() { // setTimeout( function() {