Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Demo extends React.Component {
max={10000}
min={-10}
decimals={2}
orientation="horizontal"
onValueChange={this._onNumberChange}
step={0.1}
value={this.state.numberValue}
Expand Down
11 changes: 9 additions & 2 deletions src/NumberEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class NumberEditor extends React.Component {
decimals: PropTypes.number,
max: PropTypes.number,
min: PropTypes.number,
orientation: PropTypes.string,
onValueChange: PropTypes.func,
step: PropTypes.number,
stepModifier: PropTypes.number,
Expand All @@ -48,6 +49,7 @@ class NumberEditor extends React.Component {
decimals: 0,
max: Number.MAX_VALUE,
min: -Number.MAX_VALUE,
orientation: 'horizontal',
onValueChange: () => {
// do nothing
},
Expand Down Expand Up @@ -81,7 +83,12 @@ class NumberEditor extends React.Component {

if(nextProps.dataDrag.isMoving) {
const step = this._getStepValue(nextProps.dataDrag, this.props.step);
this._changeValue(this.state.dragStartValue + nextProps.dataDrag.moveDeltaX * (step / 2));
if(this.props.orientation === 'horizontal') {
this._changeValue(this.state.dragStartValue + nextProps.dataDrag.moveDeltaX * (step / 2));
}
else if(this.props.orientation === 'vertical') {
this._changeValue(this.state.dragStartValue + nextProps.dataDrag.moveDeltaY * (step / 2));
}
}
}

Expand Down Expand Up @@ -163,7 +170,7 @@ class NumberEditor extends React.Component {
}

render() {
let cursor = 'ew-resize';
let cursor = this.props.orientation === 'horizontal' ? 'ew-resize' : 'ns-resize';
let readOnly = true;
let value = this.props.value;
if(this.state.startEditing) {
Expand Down