style: update code style

This commit is contained in:
Benjy Cui
2016-08-12 15:40:06 +08:00
parent 8fd94b4eb1
commit bc2da18f46
12 changed files with 71 additions and 71 deletions
+1 -1
View File
@@ -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);
+12 -12
View File
@@ -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() {
+2 -2
View File
@@ -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 + '%';
+1 -1
View File
@@ -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',
};