diff --git a/examples/custom-handles.js b/examples/custom-handles.js index 136fefb..ad1ea4b 100644 --- a/examples/custom-handles.js +++ b/examples/custom-handles.js @@ -4,7 +4,7 @@ const React = require('react'); const ReactDOM = require('react-dom'); const Slider = require('rc-slider'); -const wrapperStyle = {width: 400, margin: 50}; +const wrapperStyle = { width: 400, margin: 50 }; const handleStyle = { position: 'absolute', @@ -20,7 +20,7 @@ const handleStyle = { }; const CustomHandle = props => { - const style = Object.assign({left: props.offset + '%'}, handleStyle); + const style = Object.assign({ left: props.offset + '%' }, handleStyle); return (
Slider with dynamic `min` `max`
diff --git a/src/Marks.jsx b/src/Marks.jsx index fa2df2e..468ab38 100644 --- a/src/Marks.jsx +++ b/src/Marks.jsx @@ -1,7 +1,7 @@ import React from 'react'; import classNames from 'classnames'; -const Marks = ({className, vertical, marks, included, upperBound, lowerBound, max, min}) => { +const Marks = ({ className, vertical, marks, included, upperBound, lowerBound, max, min }) => { const marksKeys = Object.keys(marks); const marksCount = marksKeys.length; const unit = 100 / (marksCount - 1); diff --git a/src/Slider.jsx b/src/Slider.jsx index a83e7a0..79cd4d8 100644 --- a/src/Slider.jsx +++ b/src/Slider.jsx @@ -30,7 +30,7 @@ class Slider extends React.Component { constructor(props) { super(props); - const {range, min, max} = props; + const { range, min, max } = props; const initialValue = range ? Array.apply(null, Array(range + 1)).map(() => min) : min; const defaultValue = ('defaultValue' in props ? props.defaultValue : initialValue); const value = (props.value !== undefined ? props.value : defaultValue); @@ -46,7 +46,7 @@ class Slider extends React.Component { this.state = { handle: null, - recent: recent, + recent, bounds, }; } @@ -54,7 +54,7 @@ class Slider extends React.Component { componentWillReceiveProps(nextProps) { if (!('value' in nextProps || 'min' in nextProps || 'max' in nextProps)) return; - const {bounds} = this.state; + const { bounds } = this.state; if (nextProps.range) { const value = nextProps.value || bounds; const nextBounds = value.map(v => this.trimAlignValue(v, nextProps)); @@ -82,10 +82,10 @@ class Slider extends React.Component { if (isNotControlled) { this.setState(state); } else if (state.handle) { - this.setState({handle: state.handle}); + this.setState({ handle: state.handle }); } - const data = {...this.state, ...state}; + const data = { ...this.state, ...state }; const changedValue = props.range ? data.bounds : data.bounds[1]; props.onChange(changedValue); } @@ -160,7 +160,7 @@ class Slider extends React.Component { this.startPosition = position; const state = this.state; - const {bounds} = state; + const { bounds } = state; let valueNeedChanging = 1; if (this.props.range) { @@ -197,7 +197,7 @@ class Slider extends React.Component { } getValue() { - const {bounds} = this.state; + const { bounds } = this.state; return this.props.range ? bounds : bounds[1]; } @@ -253,8 +253,8 @@ class Slider extends React.Component { trimAlignValue(v, nextProps) { const state = this.state || {}; - const {handle, bounds} = state; - const {marks, step, min, max, allowCross} = {...this.props, ...(nextProps || {})}; + const { handle, bounds } = state; + const { marks, step, min, max, allowCross } = { ...this.props, ...(nextProps || {}) }; let val = v; if (val <= min) { @@ -343,13 +343,13 @@ class Slider extends React.Component { } calcOffset(value) { - const {min, max} = this.props; + const { min, max } = this.props; const ratio = (value - min) / (max - min); return ratio * 100; } calcValue(offset) { - const {vertical, min, max} = this.props; + const { vertical, min, max } = this.props; const ratio = Math.abs(offset / this.getSliderLength()); const value = vertical ? (1 - ratio) * (max - min) + min : ratio * (max - min) + min; return value; @@ -385,7 +385,7 @@ class Slider extends React.Component { end(type) { this.removeEvents(type); this.props.onAfterChange(this.getValue()); - this.setState({handle: null}); + this.setState({ handle: null }); } render() { diff --git a/src/Steps.jsx b/src/Steps.jsx index 208f10a..8234148 100644 --- a/src/Steps.jsx +++ b/src/Steps.jsx @@ -14,8 +14,8 @@ function calcPoints(vertical, marks, dots, step, min, max) { return points; } -const Steps = ({prefixCls, vertical, marks, dots, step, included, - lowerBound, upperBound, max, min}) => { +const Steps = ({ prefixCls, vertical, marks, dots, step, included, + lowerBound, upperBound, max, min }) => { const range = max - min; const elements = calcPoints(vertical, marks, dots, step, min, max).map((point) => { const offset = Math.abs(point - min) / range * 100 + '%'; diff --git a/src/Track.jsx b/src/Track.jsx index bcecba2..dcc2cbe 100644 --- a/src/Track.jsx +++ b/src/Track.jsx @@ -1,6 +1,6 @@ import React from 'react'; -const Track = ({className, included, vertical, offset, length}) => { +const Track = ({ className, included, vertical, offset, length }) => { const style = { visibility: included ? 'visible' : 'hidden', }; diff --git a/tests/index.spec.js b/tests/index.spec.js index 0cfd732..8c878a3 100644 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -175,7 +175,7 @@ describe('rc-slider', function test() { }); it('should render marks correctly when `marks` is not an empty object', () => { - const marks = {0: '0', 30: '30', 100: '100'}; + const marks = { 0: '0', 30: '30', 100: '100' }; const slider = ReactDOM.render(