Skip to content

Commit

Permalink
Remove redundant 'defaultValue'. Fix bug when 'min' greater than zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI committed Oct 9, 2015
1 parent 2b6c3f7 commit 29964f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
10 changes: 2 additions & 8 deletions docs/src/app/components/pages/components/sliders.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ class SlidersPage extends React.Component {
header: 'required',
desc: 'The name of the slider. Behaves like the name attribute of an input element.'
},
{
name: 'defaultValue',
type: 'number',
header: 'default: 0',
desc: 'The default value of the slider.'
},
{
name: 'description',
type: 'string',
Expand Down Expand Up @@ -131,8 +125,8 @@ class SlidersPage extends React.Component {
componentInfo={componentInfo}>
<CodeExample code={Code}>
<Slider name="slider1" />
<Slider name="slider2" defaultValue={0.5} step={0.10} />
<Slider name="slider3" defaultValue={1}/>
<Slider name="slider2" value={0.5} step={0.10} />
<Slider name="slider3" value={1}/>
<Slider name="slider1" disabled={true} />
<Slider name="slider2" disabled={true} value={0.5} />
<Slider name="slider3" disabled={true} value={1} />
Expand Down
4 changes: 2 additions & 2 deletions docs/src/app/components/raw-code/sliders-code.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//Default
<Slider name="slider1" />
// With starting value
<Slider name="slider2" defaultValue={0.5} step={0.10} />
<Slider name="slider3" defaultValue={1} />
<Slider name="slider2" value={0.5} step={0.10} />
<Slider name="slider3" value={1} />
// Disabled with fixed value
<Slider name="slider1" disabled={true} />
<Slider name="slider2" disabled={true} value={0.5} />
Expand Down
4 changes: 1 addition & 3 deletions src/slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const Slider = React.createClass({

propTypes: {
name: React.PropTypes.string.isRequired,
defaultValue: valueInRangePropType,
description: React.PropTypes.string,
disabled: React.PropTypes.bool,
error: React.PropTypes.string,
Expand Down Expand Up @@ -80,7 +79,6 @@ const Slider = React.createClass({

getDefaultProps() {
return {
defaultValue: 0,
disabled: false,
max: 1,
min: 0,
Expand All @@ -92,7 +90,7 @@ const Slider = React.createClass({
getInitialState() {
let value = this.props.value;
if (value === undefined) {
value = this.props.defaultValue;
value = this.props.min;
}
let percent = (value - this.props.min) / (this.props.max - this.props.min);
if (isNaN(percent)) percent = 0;
Expand Down

0 comments on commit 29964f5

Please sign in to comment.