mirror of
https://github.com/wassname/slider.git
synced 2026-09-12 12:50:45 +08:00
feat: add support for range
This commit is contained in:
+23
-10
@@ -4,6 +4,7 @@ require('rc-slider/assets/index.less');
|
||||
|
||||
var React = require('react');
|
||||
var Slider = require('rc-slider');
|
||||
var style = {width:400,margin:100};
|
||||
|
||||
function onChange(v) {
|
||||
console.log(v);
|
||||
@@ -11,23 +12,35 @@ function onChange(v) {
|
||||
|
||||
React.render(
|
||||
<div>
|
||||
<div style={{width:400,margin:100}}>
|
||||
<Slider onChange={onChange} tipTransitionName='rc-slider-tooltip-zoom-down'/>
|
||||
<div style={style}>
|
||||
<Slider onChange={onChange} tipTransitionName='rc-slider-tooltip-zoom-down' />
|
||||
</div>
|
||||
<div style={{width:400,margin:100}}>
|
||||
<Slider marks={["一","二","三","四","五"]} defaultIndex={2}/>
|
||||
<div style={style}>
|
||||
<Slider marks={["一","二","三","四","五"]} defaultIndex={2} />
|
||||
</div>
|
||||
<div style={{width:400,margin:100}}>
|
||||
<Slider withDots step={20}/>
|
||||
<div style={style}>
|
||||
<Slider withDots step={20} />
|
||||
</div>
|
||||
<div style={{width:400,margin:100}}>
|
||||
<Slider step={20}/>
|
||||
<div style={style}>
|
||||
<Slider step={20} />
|
||||
</div>
|
||||
<div style={{width:400,margin:100}}>
|
||||
<div style={style}>
|
||||
<Slider range={true} min={10} max={90} values={[0, 30]} onChange={onChange} />
|
||||
</div>
|
||||
<div style={style}>
|
||||
<Slider range={true} withDots step={20} values={[0, 30]} onChange={onChange} isIncluded={false} />
|
||||
</div>
|
||||
<div style={style}>
|
||||
<Slider range={true} withDots step={20} values={[0, 0]} onChange={onChange} isIncluded={false} />
|
||||
</div>
|
||||
<div style={style}>
|
||||
<Slider range={true} withDots step={20} values={[100, 100]} onChange={onChange} isIncluded={false} />
|
||||
</div>
|
||||
<div style={style}>
|
||||
<p>包含关系</p>
|
||||
<Slider marks={["状态1","状态2","状态3","状态4"]} defaultIndex={1} />
|
||||
</div>
|
||||
<div style={{width:400,margin:100}}>
|
||||
<div style={style}>
|
||||
<p>并列关系</p>
|
||||
<Slider marks={["状态1","状态2","状态3","状态4"]} isIncluded={false} defaultIndex={1} />
|
||||
</div>
|
||||
|
||||
+12
-11
@@ -10,6 +10,18 @@ export default class Handle extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
showTooltip() {
|
||||
this.setState({
|
||||
isTooltipVisible: true,
|
||||
});
|
||||
}
|
||||
|
||||
hideTooltip() {
|
||||
this.setState({
|
||||
isTooltipVisible: false,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const props = this.props;
|
||||
const {className, tipTransitionName, offset, value} = props;
|
||||
@@ -36,17 +48,6 @@ export default class Handle extends React.Component {
|
||||
{handle}
|
||||
</Tooltip>);
|
||||
}
|
||||
|
||||
showTooltip() {
|
||||
this.setState({
|
||||
isTooltipVisible: true,
|
||||
});
|
||||
}
|
||||
hideTooltip() {
|
||||
this.setState({
|
||||
isTooltipVisible: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Handle.propTypes = {
|
||||
|
||||
+188
-124
@@ -30,46 +30,62 @@ function pauseEvent(e) {
|
||||
}
|
||||
}
|
||||
|
||||
function getValueFromIndex(props) {
|
||||
const marksLen = props.marks.length;
|
||||
const index = ('index' in props ? props.index : props.defaultIndex);
|
||||
|
||||
let value;
|
||||
if (marksLen > 0) {
|
||||
value = ((props.max - props.min) / (marksLen - 1)) * (index);
|
||||
value = value.toFixed(5);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
class Slider extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
// Note: Maybe `value` is `0`, `false` and so on.
|
||||
// So, check the existence of `value` with `in`.
|
||||
let value = ('value' in props ? props.value : props.defaultValue);
|
||||
value = this._trimAlignValue(value);
|
||||
let upperBound;
|
||||
let lowerBound;
|
||||
if (props.range) {
|
||||
const values = (props.values || props.defaultValues);
|
||||
upperBound = this.trimAlignValue(values[1]);
|
||||
lowerBound = this.trimAlignValue(values[0]);
|
||||
} else if (props.marks.length > 0) {
|
||||
upperBound = this.calcValueFromProps(props);
|
||||
} else {
|
||||
// Note: Maybe `value` is `0`.
|
||||
// So, check the existence of `value` with `in`.
|
||||
const value = ('value' in props ? props.value : props.defaultValue);
|
||||
upperBound = this.trimAlignValue(value);
|
||||
}
|
||||
|
||||
const marksLen = props.marks.length;
|
||||
if (marksLen > 0) {
|
||||
value = getValueFromIndex(props);
|
||||
let recent;
|
||||
if (props.range && upperBound === lowerBound) {
|
||||
if (lowerBound === props.max) {
|
||||
recent = 'lowerBound';
|
||||
}
|
||||
if (upperBound === props.min) {
|
||||
recent = 'upperBound';
|
||||
}
|
||||
} else {
|
||||
recent = 'upperBound';
|
||||
}
|
||||
|
||||
this.state = {
|
||||
dragging: false,
|
||||
value: value,
|
||||
handle: null,
|
||||
recent: recent,
|
||||
upperBound: upperBound,
|
||||
// If Slider is not range, set `lowerBound` equal to `min`.
|
||||
lowerBound: (lowerBound || props.min),
|
||||
};
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if ('value' in nextProps) {
|
||||
if (nextProps.range) {
|
||||
const values = nextProps.values;
|
||||
if (values) {
|
||||
this.setState({
|
||||
upperBound: values[1],
|
||||
lowerBound: values[0],
|
||||
});
|
||||
}
|
||||
} else if ('value' in nextProps) {
|
||||
this.setState({
|
||||
value: nextProps.value,
|
||||
upperBound: nextProps.value,
|
||||
});
|
||||
} else if ('index' in nextProps) {
|
||||
this.setState({
|
||||
value: getValueFromIndex(nextProps),
|
||||
upperBound: this.calcValueFromProps(nextProps),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -94,19 +110,24 @@ class Slider extends React.Component {
|
||||
const props = this.props;
|
||||
const state = this.state;
|
||||
|
||||
let value = state.value;
|
||||
const oldValue = value;
|
||||
|
||||
const diffPosition = position - this.startPosition;
|
||||
|
||||
const diffValue = diffPosition / this.getSliderLength() * (props.max - props.min);
|
||||
value = this._trimAlignValue(this.startValue + diffValue);
|
||||
|
||||
if (value !== oldValue && !('value' in props) && !('index' in props)) {
|
||||
this.setState({value: value});
|
||||
const value = this.trimAlignValue(this.startValue + diffValue);
|
||||
const oldValue = state[state.handle];
|
||||
if (value === oldValue) return;
|
||||
|
||||
if (!('value' in props) && !('index' in props)) {
|
||||
this.setState({[state.handle]: value});
|
||||
}
|
||||
if (value !== oldValue) {
|
||||
this._triggerEvents('onChange', value);
|
||||
|
||||
if (props.range) {
|
||||
// `this.state` will not be updated immediately after `this.setState`.
|
||||
// So, create a similar object.
|
||||
const data = Object.assign({}, state, {[state.handle]: value});
|
||||
this.triggerEvents('onChange', [data.lowerBound, data.upperBound]);
|
||||
} else {
|
||||
this.triggerEvents('onChange', value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,30 +135,52 @@ class Slider extends React.Component {
|
||||
if (isNotTouchEvent(e)) return;
|
||||
|
||||
const position = getTouchPosition(e);
|
||||
const value = this._calValueByPos(position);
|
||||
this._triggerEvents('onChange', value);
|
||||
this._start(position, value);
|
||||
this._addDocumentEvents('touch');
|
||||
this.onStart(position);
|
||||
this.addDocumentEvents('touch');
|
||||
pauseEvent(e);
|
||||
}
|
||||
|
||||
onSliderMouseDown(e) {
|
||||
const position = getMousePosition(e);
|
||||
const value = this._calValueByPos(position);
|
||||
this._triggerEvents('onChange', value);
|
||||
this._start(position, value);
|
||||
this._addDocumentEvents('mouse');
|
||||
this.onStart(position);
|
||||
this.addDocumentEvents('mouse');
|
||||
pauseEvent(e);
|
||||
}
|
||||
|
||||
getIndex(v) {
|
||||
const props = this.props;
|
||||
const value = v === undefined ? this.state.value : v;
|
||||
onStart(position) {
|
||||
this.triggerEvents('onBeforeChange');
|
||||
|
||||
if (props.marks.length === 0) {
|
||||
return Math.floor((value - props.min) / props.step);
|
||||
const value = this.calcValueByPos(position);
|
||||
this.startValue = value;
|
||||
this.startPosition = position;
|
||||
|
||||
const {upperBound, lowerBound} = this.state;
|
||||
const isUpperBoundCloser = Math.abs(upperBound - value) < Math.abs(lowerBound - value);
|
||||
let valueNeedChanging = (!this.props.range || isUpperBoundCloser) ? 'upperBound' : 'lowerBound';
|
||||
const isAtTheSamePoint = (upperBound === lowerBound);
|
||||
valueNeedChanging = isAtTheSamePoint ? this.state.recent : valueNeedChanging;
|
||||
|
||||
this.setState({
|
||||
handle: valueNeedChanging,
|
||||
recent: valueNeedChanging,
|
||||
[valueNeedChanging]: value,
|
||||
});
|
||||
|
||||
if (this.props.range) {
|
||||
const data = Object.assign({}, this.state, {[valueNeedChanging]: value});
|
||||
this.triggerEvents('onChange', [data.lowerBound, data.upperBound]);
|
||||
} else {
|
||||
this.triggerEvents('onChange', value);
|
||||
}
|
||||
const unit = ((props.max - props.min) / (props.marks.length - 1)).toFixed(5);
|
||||
}
|
||||
|
||||
getIndex(value) {
|
||||
const {marks, min, max, step} = this.props;
|
||||
|
||||
if (marks.length === 0) {
|
||||
return Math.floor((value - min) / step);
|
||||
}
|
||||
const unit = ((max - min) / (marks.length - 1)).toFixed(5);
|
||||
return Math.round(value / unit);
|
||||
}
|
||||
|
||||
@@ -157,71 +200,25 @@ class Slider extends React.Component {
|
||||
return rect.left;
|
||||
}
|
||||
|
||||
render() {
|
||||
const state = this.state;
|
||||
const {value, dragging} = state;
|
||||
trimAlignValue(v) {
|
||||
const state = this.state || {};
|
||||
const props = this.props;
|
||||
const {className, prefixCls, disabled, isIncluded, withDots} = props;
|
||||
const {marks, step, max, min, tipTransitionName, children} = props;
|
||||
const marksLen = marks.length;
|
||||
|
||||
const sliderClassName = rcUtil.classSet({
|
||||
[prefixCls]: true,
|
||||
[prefixCls + '-disabled']: disabled,
|
||||
[className]: !!className,
|
||||
});
|
||||
|
||||
const offset = this._calcOffset(value);
|
||||
|
||||
let track = null;
|
||||
if (isIncluded) {
|
||||
const trackClassName = prefixCls + '-track';
|
||||
track = <Track className={trackClassName} offset={0} length={offset - 0} />;
|
||||
}
|
||||
|
||||
const handleClassName = prefixCls + '-handle';
|
||||
|
||||
let steps = null;
|
||||
if (marksLen > 0 || (step > 1 && withDots)) {
|
||||
const stepsClassName = prefixCls + '-step';
|
||||
const stepNum = marksLen > 0 ? marksLen : Math.floor((max - min) / step) + 1;
|
||||
steps = (<Steps className={stepsClassName} stepNum={stepNum}
|
||||
index={this.getIndex()} isIncluded={isIncluded} />);
|
||||
}
|
||||
|
||||
let mark = null;
|
||||
if (marksLen > 0) {
|
||||
const markClassName = prefixCls + '-mark';
|
||||
mark = (<Marks className={markClassName} marks={marks}
|
||||
index={this.getIndex()} isIncluded={isIncluded} />);
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref="slider" className={sliderClassName}
|
||||
onTouchStart={disabled ? noop : this.onTouchStart.bind(this)}
|
||||
onMouseDown={disabled ? noop : this.onSliderMouseDown.bind(this)}>
|
||||
{track}
|
||||
<Handle className={handleClassName} tipTransitionName={tipTransitionName}
|
||||
offset={offset} value={value} dragging={dragging} noTip={marksLen > 0} />
|
||||
{steps}
|
||||
{mark}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
_trimAlignValue(v, propsArg) {
|
||||
let val = v;
|
||||
const props = propsArg || this.props;
|
||||
const {marks, min, max} = props;
|
||||
const step = marks.length > 0 ? (max - min) / (marks.length - 1) : props.step;
|
||||
|
||||
let val = v;
|
||||
if (val <= min) {
|
||||
val = min;
|
||||
}
|
||||
if (val >= max) {
|
||||
val = max;
|
||||
}
|
||||
if (state.handle === 'upperBound' && val <= state.lowerBound) {
|
||||
val = state.lowerBound;
|
||||
}
|
||||
if (state.handle === 'lowerBound' && val >= state.upperBound) {
|
||||
val = state.upperBound;
|
||||
}
|
||||
|
||||
const valModStep = (val - min) % step;
|
||||
let alignValue = val - valModStep;
|
||||
@@ -233,28 +230,36 @@ class Slider extends React.Component {
|
||||
return parseFloat(alignValue.toFixed(5));
|
||||
}
|
||||
|
||||
_calcOffset(value) {
|
||||
calcOffset(value) {
|
||||
const {min, max} = this.props;
|
||||
const ratio = (value - min) / (max - min);
|
||||
return ratio * 100;
|
||||
}
|
||||
|
||||
_calcValue(offset) {
|
||||
calcValue(offset) {
|
||||
const {min, max} = this.props;
|
||||
const ratio = offset / this.getSliderLength();
|
||||
return ratio * (max - min) + min;
|
||||
}
|
||||
|
||||
_calValueByPos(position) {
|
||||
calcValueByPos(position) {
|
||||
const pixelOffset = position - this.getSliderStart();
|
||||
const nextValue = this._trimAlignValue(this._calcValue(pixelOffset));
|
||||
this.setState({
|
||||
value: nextValue,
|
||||
});
|
||||
const nextValue = this.trimAlignValue(this.calcValue(pixelOffset));
|
||||
return nextValue;
|
||||
}
|
||||
|
||||
_triggerEvents(event, v) {
|
||||
calcValueFromProps(props) {
|
||||
const marksLen = props.marks.length;
|
||||
if (marksLen > 0) {
|
||||
const index = ('index' in props ? props.index : props.defaultIndex);
|
||||
const value = ((props.max - props.min) / (marksLen - 1)) * (index);
|
||||
// `'1' / 1 => 1`, to make sure that the returned value is a `Number`.
|
||||
return value.toFixed(5) / 1;
|
||||
}
|
||||
return ('value' in props ? props.value : props.defaultValue);
|
||||
}
|
||||
|
||||
triggerEvents(event, v) {
|
||||
const props = this.props;
|
||||
const hasMarks = (props.marks.length > 0);
|
||||
if (props[event]) {
|
||||
@@ -270,7 +275,7 @@ class Slider extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
_addDocumentEvents(type) {
|
||||
addDocumentEvents(type) {
|
||||
if (type === 'touch') {
|
||||
// just work for chrome iOS Safari and Android Browser
|
||||
this.onTouchMoveListener = DomUtils.addEventListener(document, 'touchmove', this.onTouchMove.bind(this));
|
||||
@@ -281,7 +286,7 @@ class Slider extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
_removeEventons(type) {
|
||||
removeEventons(type) {
|
||||
if (type === 'touch') {
|
||||
this.onTouchMoveListener.remove();
|
||||
this.onTouchUpListener.remove();
|
||||
@@ -291,21 +296,75 @@ class Slider extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
_start(position, value) {
|
||||
this._triggerEvents('onBeforeChange');
|
||||
this.startValue = value;
|
||||
this.startPosition = position;
|
||||
this.setState({
|
||||
dragging: true,
|
||||
});
|
||||
end(type) {
|
||||
this.removeEventons(type);
|
||||
this.triggerEvents('onAfterChange');
|
||||
this.setState({ handle: null });
|
||||
}
|
||||
|
||||
end(type) {
|
||||
this._removeEventons(type);
|
||||
this._triggerEvents('onAfterChange');
|
||||
this.setState({
|
||||
dragging: false,
|
||||
render() {
|
||||
const {handle, upperBound, lowerBound} = this.state;
|
||||
const props = this.props;
|
||||
const {className, prefixCls, disabled, isIncluded, withDots, range} = props;
|
||||
const {marks, step, max, min, tipTransitionName, children} = props;
|
||||
const marksLen = marks.length;
|
||||
|
||||
const sliderClassName = rcUtil.classSet({
|
||||
[prefixCls]: true,
|
||||
[prefixCls + '-disabled']: disabled,
|
||||
[className]: !!className,
|
||||
});
|
||||
|
||||
const upperOffset = this.calcOffset(upperBound);
|
||||
const lowerOffset = this.calcOffset(lowerBound);
|
||||
|
||||
let track = null;
|
||||
if (isIncluded || range) {
|
||||
const trackClassName = prefixCls + '-track';
|
||||
track = <Track className={trackClassName} offset={lowerOffset} length={upperOffset - lowerOffset} />;
|
||||
}
|
||||
|
||||
const handleClassName = prefixCls + '-handle';
|
||||
const isNoTip = marksLen > 0;
|
||||
const upper = (<Handle className={handleClassName} tipTransitionName={tipTransitionName} noTip={isNoTip}
|
||||
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'} />);
|
||||
}
|
||||
|
||||
const upperIndex = this.getIndex(upperBound);
|
||||
|
||||
let steps = null;
|
||||
if (marksLen > 0 || (step > 1 && withDots)) {
|
||||
const stepsClassName = prefixCls + '-step';
|
||||
const stepNum = marksLen > 0 ? marksLen : Math.floor((max - min) / step) + 1;
|
||||
steps = (<Steps className={stepsClassName} stepNum={stepNum}
|
||||
lowerIndex={this.getIndex(lowerBound)} upperIndex={upperIndex}
|
||||
isIncluded={isIncluded || range} />);
|
||||
}
|
||||
|
||||
let mark = null;
|
||||
if (marksLen > 0) {
|
||||
const markClassName = prefixCls + '-mark';
|
||||
mark = (<Marks className={markClassName} marks={marks}
|
||||
index={upperIndex} isIncluded={isIncluded} />);
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref="slider" className={sliderClassName}
|
||||
onTouchStart={disabled ? noop : this.onTouchStart.bind(this)}
|
||||
onMouseDown={disabled ? noop : this.onSliderMouseDown.bind(this)}>
|
||||
{track}
|
||||
{upper}
|
||||
{lower}
|
||||
{steps}
|
||||
{mark}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,8 +373,10 @@ Slider.propTypes = {
|
||||
max: React.PropTypes.number,
|
||||
step: React.PropTypes.number,
|
||||
defaultValue: React.PropTypes.number,
|
||||
defaultValues: React.PropTypes.arrayOf(React.PropTypes.number),
|
||||
defaultIndex: React.PropTypes.number,
|
||||
value: React.PropTypes.number,
|
||||
values: React.PropTypes.arrayOf(React.PropTypes.number),
|
||||
index: React.PropTypes.number,
|
||||
marks: React.PropTypes.array,
|
||||
isIncluded: React.PropTypes.bool,
|
||||
@@ -328,6 +389,7 @@ Slider.propTypes = {
|
||||
onAfterChange: React.PropTypes.func,
|
||||
tipTransitionName: React.PropTypes.string,
|
||||
withDots: React.PropTypes.bool,
|
||||
range: React.PropTypes.bool,
|
||||
};
|
||||
|
||||
Slider.defaultProps = {
|
||||
@@ -335,6 +397,7 @@ Slider.defaultProps = {
|
||||
max: 100,
|
||||
step: 1,
|
||||
defaultValue: 0,
|
||||
defaultValues: [0, 0],
|
||||
defaultIndex: 0,
|
||||
marks: [],
|
||||
isIncluded: true,
|
||||
@@ -343,6 +406,7 @@ Slider.defaultProps = {
|
||||
disabled: false,
|
||||
tipTransitionName: '',
|
||||
withDots: false,
|
||||
range: false,
|
||||
};
|
||||
|
||||
export default Slider;
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import rcUtil from 'rc-util';
|
||||
|
||||
const Steps = ({className, stepNum, isIncluded, index}) => {
|
||||
const Steps = ({className, stepNum, isIncluded, lowerIndex, upperIndex}) => {
|
||||
const dotClassName = className.replace('step', 'dot');
|
||||
const unit = 100 / (stepNum - 1);
|
||||
|
||||
@@ -10,7 +10,8 @@ const Steps = ({className, stepNum, isIncluded, index}) => {
|
||||
const offset = unit * i + '%';
|
||||
const style = { left: offset };
|
||||
|
||||
const isActived = (isIncluded && i <= index) || (!isIncluded && i === index);
|
||||
const isActived = (isIncluded && i <= upperIndex && i >= lowerIndex ) ||
|
||||
(!isIncluded && i === upperIndex);
|
||||
const stepClassName = rcUtil.classSet({
|
||||
[dotClassName]: true,
|
||||
[dotClassName + '-active']: isActived,
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ 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(slider.state.value).to.be(40);
|
||||
expect(slider.state.upperBound).to.be(40);
|
||||
var trackWidth = node.find('.rc-slider-track')[0].style.width;
|
||||
expect(trackWidth).to.eql(node.find('.rc-slider-handle')[0].style.left);
|
||||
});
|
||||
@@ -40,7 +40,7 @@ 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(slider.state.value).to.be(0);
|
||||
expect(slider.state.upperBound).to.be(0);
|
||||
|
||||
var sliderWithDots = React.render(
|
||||
<Slider className='rc-slider' step={20} withDots/>,
|
||||
@@ -62,7 +62,7 @@ describe('rc-slider', function () {
|
||||
expect(node.find('.rc-slider-dot').length).to.be(slider.props.marks.length);
|
||||
expect(node.find('.rc-slider-mark').length).to.be(1);
|
||||
expect(node.find('.rc-slider-mark-text').length).to.be(slider.props.marks.length);
|
||||
expect(slider.getIndex()).to.be(3);
|
||||
expect(slider.getIndex(slider.state.upperBound)).to.be(3);
|
||||
});
|
||||
|
||||
// it('should mouseDown works!', function (done) {
|
||||
|
||||
Reference in New Issue
Block a user